The Argentinian, who came off the bench, opened the scoring before Albert Adomah added a second late on as the Lions saw a seven-game unbeaten run at The Den end.
Marvin Emnes had the first opening of the game when he made himself half a yard in a wide position - but Mark Beevers cleared his low cross.
In the 17th minute Lions goalkeeper David Forde had to be quick to hack the ball into touch after Emnes had chased down Alan Dunne's backpass.
Boro defender Daniel Ayala was booked for a lunge on Liam Trotter after half-an-hour, despite the defender receiving the free-kick having been tripped by Scott McDonald.
Liam Feeney provided Millwall with their best moment of the first half when he burst down the right, but his tame cross could only find Jozsef Varga.
Ledesma's curling free-kick then came off the head of Paul Robinson and landed in the arms of Forde after 40 minutes as a drab opening period came towards its close.
It took until 42 minutes for the game's first shot to arrive and it came through Lions defender Dunne who fired straight at Shay Given from 25 yards.
But four minutes after the restart Ledesma broke down the right, cut inside Paul Robinson and Nadjim Abdou and fired beyond Forde from 20 yards.
McDonald was booked for a reckless tackle on Dean Whitehead soon after, and the Boro midfielder was fortunate to escape without punishment as he squared up to the Australian.
Steve Morison forced on-loan Aston Villa goalkeeper Given into action on 69 minutes, with the Irishman having to dive to his left to palm the striker's header away.
Two minutes later Richard Smallwood should have made it two but he fired Ledesma's cutback over from 10 yards.
With 13 minutes remaining Trotter almost glanced Ledesma's corner into his own net when he touched it on at the near post, but fortunately for him the ball drifted just wide.
And, at the other end, the midfielder came close to levelling a minute later when he shot left-footed from 20 yards - but the effort sailed just over.
Ledesma then had the chance to seal the victory with four minutes left. He spotted Forde off his line and attempted a deft chip but the goalkeeper got his fingertips to the ball to prevent it finding the top corner, then scrambled it away from his own line.
However, Forde could do little to prevent Adomah wrapping up the points in the final minute as the Ghanaian rounded him and tapped into an empty net.