There are two ways in which a massive orbiting body, such as a planet, can clear a smaller object from the vicinity of its orbit. One, obviously, is by colliding with it. The other, more common way is called the gravitational slingshot effect.*
This is a trick that many space probes have used to gain (or lose) extra speed and thus get further away from (or closer to) the sun, but it's also something that happens completely naturally.
Basically, when the smaller object passes close to the planet, the gravitational pull of the planet will cause the small object's path to curve.** Viewed from the planet's reference frame, the small object will follow an (approximately) hyperbolic fly-by trajectory, arriving and leaving at the same speed (relative to the planet) but in a different direction.
However, the planet is also in orbit around the sun, and thus moving relative to it. If the new direction in which the small object leaves the planet's vicinity after the encounter happens to point the same way as the planet is moving in its orbit, the object will end up moving in the same direction as the planet but faster, and will thus be flung outwards from the sun.
(Conversely, if the object leaves the planet's vicinity in the opposite direction to the way the planet is moving in its orbit relative to the sun, then the opposite velocities will (partially) cancel out and the object will end up losing speed and thus falling inwards towards the sun — possibly even into the sun, if it manages to lose enough velocity.)
To illustrate this visually — a picture often being worth a thousand words — here's a couple of screenshots from Kerbal Space Program. (Because why the heck not? KSP's orbital mechanics model is a bit simplified compared to real life — it basically follows the patched conic approximation — but it's quite sufficient for modeling gravitational slingshots.)
The first screenshot below shows a small asteroid — mysteriously labelled as "Unknown Object" on the map — that has fortuitously (or, rather, via shameless use of KSP's cheat menu) been captured into a temporary orbit around the planet Kerbin, KSP's Earth-analogue (shown as the dark blue sphere in the exact center of the map). The reason why the asteroid's current orbit (blue-green line) is only temporary*** is that it's quite close to the orbit of the larger of Kerbin's two moons, creatively named "The Mun", soon resulting in a near pass:
As the asteroid passes by the Mun (orange line), it ends up getting flung in (more or less) the same direction as the Mun is orbiting Kerbin, gaining a bunch of extra speed relative to Kerbin and, in fact, getting ejected from the Kerbin system entirely (purple line).
(In real life, the extra momentum gained by the asteroid would be balanced by a corresponding loss of momentum by the Mun, slowing it down very, very slightly. Since the Mun is much bigger than the asteroid, however, the slowdown is so negligible that KSP doesn't even try to model it.)
Meanwhile, here's the same close pass as seen from the Mun's viewpoint:
As you can see, in this reference frame the fly-by trajectory looks quite symmetric: the asteroid falls towards the Mun (but not so directly that it would crash into it), accelerating as it's pulled closer by the Mun's gravity, and then starts slowing down again after passing the closest point of approach (marked as "periapsis" on the map). But the end result is that the asteroid leaves the Mun's vicinity in a different direction, and that change in direction is enough to put it into a completely different orbit around Kerbin — in this case, one that ends up taking it out of Kerbin's vicinity entirely. Thus the Mun has once again cleared its orbit of such pesky intruders.
*) There's a kind of a third way, too, where the planet and the smaller object end up in an orbital resonance that gradually transfers momentum from the planet to the small object without them ever getting very close to each other. You can sort of think of such a resonance like a series of very slight gravitational slingshots, each of which nudges the smaller object's orbit further and further in the same direction.
**) Obviously, the converse happens too, but if the smaller object is much smaller than the planet, then its effect on the planet's motion will be negligible.
***) It's actually quite natural for a captured asteroid to end up in such an unstable orbit: since orbital mechanics is time-symmetric, both in KSP and in real life, if we traced the asteroid's orbit backwards in time we'd presumably find another, earlier encounter with the Mun that would've caused it to be captured into its current temporary orbit in the first place. In real life, the Earth every once in a while also captures such temporary satellites, but their orbits are also basically never stable, since the same gravitational interactions that allowed them to be captured will also, by time symmetry, eventually allow them to escape again. (Of course, in this case I was actually lazy and just cheated the asteroid into that orbit, rather than waiting for one to be "naturally" captured.)