Karl Robinson's side had fallen behind in the first-half courtesy of Michael Smith's finish but after a powerful header from Antony Kay levelled things up, Baldock secured a valuable three points with an unstoppable 93rd minute winner.
The result sees the Dons climb two places to seventh in Sky Bet League 1 and remain just six points adrift of the play-off places with 11 games to go.
Having stressed the importance of the clash before kick-off, Robinson opted for a slight change in formation with Larnell Cole, Izale McLeod and Sanmi Odelusi forming an attacking trio ahead of a midfield pairing of Ben Reeves and Dele Alli. The experienced Alan Smith took up a position just in-front of the defence.
After an even start to the game, Reeves was the first to register a shot on target when he stung the palms of Tyrell Belford with a 35-yard free-kick on 7 minutes.
Reeves then turned provider, setting Odelusi free down the left wing before the loanee cut inside and drilled an effort just wide of the right upright.
The Dons were by far the more dominant side but despite some good play in the wide areas the crucial final ball was lacking.
And in the 18th minute they were made to rue when Swindon, on a rare attack forward, opened the scoring through their striker Smith, who was in the right place at the right time to nod in from close range after Martin had failed to deal with Alex Pritchard’s long-distance effort.
The hard-working Reeves tried to level things up with a shot of his own from outside the area soon after but unlike Pritchard moments earlier, he failed to find the target.
The goal had clearly taken the sting out of Robinson’s men and if not for a smart Martin save on the half hour they could have been two-nil down; the Dons ‘keeper did well to react to Luongo’s glanced header and hold onto the effort under pressure.
Former Don Ryan Harley then went close for the hosts with a left-footed shot which was deflected behind by Baldock before Troy Archibald-Henville drilled wide from the resulting corner.
Eager not to fall further behind, the Dons finally began to find their feet as they went in search of a leveller before the interval. Reeves’ teasing free-kick provided the best opportunity for that equalising goal but Kay wasn’t able to latch onto it and Belford claimed comfortably.
Robinson made just the one change at half-time with Daniel Powell replacing Cole but he was almost forced into another switch soon after the re-start when defender Jordan Spence went down holding his ankle.
15-year-old Danny Collinge was sent to warm-up while Spence received treatment but after a lengthy delay the man on loan from West Ham was able to continue. His first involvement after returning to the field was to attack a Dele Alli free-kick which was flicked wide of the upright by his team-mate Kay.
The Dons were looking the more likely to score the crucial second goal and Reeves went agonisingly close with a free-kick of his own in the 65th minute.
Eventually, though, the men from MK1 found their equaliser and it came from the unlikely source of defender Kay, who climbed above everybody from Reeves’ corner to power a header past Belford and level the scores up.
Kay and his team-mates did, however, have Martin to thank for keeping the score at 1-1 just a minute later, when the 'keeper correctly judged Pritchard’s clever free-kick and made a strong save at his near post.
Robinson then introduced Dean Bowditch from the bench for his first appearance since February and the winger came close to creating a second goal for the Dons but after finding McLeod with a neat pass, the striker's shot was well saved by Belford at his near post.
On 87 minutes, Bowditch, himself, had a glorious opportunity to mark his comeback with a winning goal but, once again, Belford did well to save low down to his right.
With the game finely poised, the stage was set for someone to steal the headlines and deep into stoppage time, Baldock did exactly that. After receiving the ball out wide, the right-back cut inside and drilled an unstoppable shot into the top corner to win the game for his side.
Swindon Town: Belford, Thompson (McEveley 83), Byrne, Luongo, Harley, Pritchard, Kasim (Murphy 69), Thompson, Ward (c), Smith (N'Guessan 86), Archibald-Henville.
Subs not used: Bedwell (GK), Rossi-Branco, Barker, Gladwin.
Goal: Smith 19
MK Dons (4-3-3): Martin; Baldock, Spence, Kay, Lewington (c); Smith; Alli, Reeves; Cole (Powell 46), McLeod, Odelusi (Bowditch 76).
Subs not used: Burns (GK), Chadwick, Rasulo, Hall, Collinge.
Booked: Kay, Baldock
Goal: Kay 60, Baldock 90
Referee: J Simpson
Attendance: 7,424 (322 away)