Late goals from Wesley Sneijder and Samuel Eto'o took Leonardo's side above Napoli into second place in the standings, two points behind their city rivals.
Samp, meanwhile, are left in 14th place, just six points clear of the relegation zone after their second straight home defeat.
Sneijder tested Gianluca Curci with a direct free-kick which he curled over the wall in the 16th minute.
But it was the home side who enjoyed the better of the remainder of the first half with Daniele Dessena's shot blocked by his own team-mate Massimo Maccarone in the 29th minute.
Ten minutes later, a Dessena cross from the right created another excellent chance for Samp, but Reto Ziegler's shot was blocked by former Genoa defender Andrea Ranocchia.
As the first half drew to its conclusion, Andrea Poli cut into the area from the left and his shot struck the right-hand upright as the Nerazzurri were rather fortunate to go into the break still on terms.
Maccarone failed to beat Julio Cesar in a one-on-one situation after 62 minutes, and that proved to be Samp's last chance of the game.
Sneijder's next free-kick in the 73rd minute was unstoppable as he again curled the ball past the wall, only this time it was inch-perfect into the right-hand side of the goal.
Another Sneijder free-kick rattled the outside of the post in the 80th minute before Eto'o sealed the win in the last minute, dribbling into the area from the left and then beating Curci with aplomb.
As a result, Leonardo celebrated something which even his predecessor Jose Mourinho never managed in his two years in charge - a win over Sampdoria.
And the result increases the pressure on Milan, who host third-placed Napoli at the San Siro tomorrow night.