Your problem appears to be too much science fiction and not enough science.
In science fiction, gravity sucks things towards the planet, sort of like a magnet. When far away you don't feel it; then you get close enough, and you are pulled down to the surface. And it holds things near the planet like glue or an elastic band.
In this science fiction model, stuff in space floats because it is far away. You go to space, you float.
In the real world, the science model, in space you fall just like you do in atmosphere. Orbit isn't far away, it is fast away -- things orbit the planet because they are going extremely fast.
Things in (low) orbit are amazingly close to the planet, from a distance they are almost skimming the surface. They are just moving so fast that the gravity of the planet pulling it down isn't fast enough; they "miss" the ground on each orbit.
Gravity doesn't stick or yank; gravity accelerates. When you go down a gravity well, you gain speed. This speed is mostly towards the planet, but it takes relative precision to actually hit the planet; even a modest velocity "horizontal" to the gravity well will make you miss.
And when you are going away from the planet, gravity doesn't "stick", it decelerates. The amount it decelerates on the way out is the same as it accelerated on the way in, at least in its frame of reference.
So you can set a trajectory that skims the surface of a planet (without an atmosphere, or outside it), and you'll only lose the speed you gained while falling in.
The slingshot maneuver uses the fact that the planet's "stationary" frame of reference isn't the same as the sun. So you approach the planet from "behind" in its orbital track, then leave roughly perpendicular to its orbital track.
If the planet was moving 13 km/s and you approached it from the side at 20 km/s.
In the planet's perspective you are moving sqrt(20^2 + 13^2) = 23.9 km/s.
You then leave the planet say, parallel to the orbital track in the same direction. You leave at 23.9 km/s.
But in the sun's frame of reference, you approached the planet at 20km/s and left at (13+23.9) = 36.9 km/s, a massive speed boost.