Ali Gerba put the Dons ahead in first-half stoppage time, but Jason Taylor equalised in the second half before the home side missed a succession of chances and Paul Turnbull forced Dean Lewington into his decisive error.
The result continued Stockport's impressive away form, but Dons boss Roberto Di Matteo will have been left fuming by his side's inability to finish off their opponents.
The first half started with pace and a flurry of half chances.
The Hatters' direct running caused the Dons problems, Tony Kane firing wide and Stephen Gleeson forcing a smart save from Willy Gueret with a curling effort.
The closest either team went to scoring though was through Luke Chadwick, who hit the stanchion with a left-foot effort from the edge of the box after a corner had been partially cleared.
Minutes later Mark Wright might have done better after a dazzling passing move.
Lewington cut inside well, he played a pass to Gerba who ran over the ball, Sam Baldock laid it to Peter Leven who put Wright through, only to blaze over with the goal at his mercy.
The game quietened after that busty opening quarter of an hour and the next chance didn't come until moments before half-time, Anthony Pilkington went through one-on-one with Gueret, the big stopper made the risky decision to close him down and fortunately he shot straight at his chest.
And they were made to rue that miss as soon after another slick move Leven played through Gerba, who just nicked in front of Fraser Forster to prod home.
Jim Gannon sent his troops out with well over five minutes of half-time remaining and it worked when on 57 minutes Pilkington's corner wasn't cleared and Taylor was able to tap in at the back post.
The Dons, helped by the roar of the home fans were straight back on the attack and dominated the rest of the game.
A Wright cross-cum-shot was almost flicked in at the near post by Gerba.
Then Chadwick went close for the second time when he cut in and curled a right-foot shot somehow went past the post.
Dons continued to lay siege to the Hatters' goal and Miguel Angel Llera forced a full-stretch save from Forster with a header that he just couldn't generate enough pace on.
Then came the chance that should have won it as Shaun Cummings' cross just went over Baldock but fell at the feet of sub Kevin Gallen, who with the goal gaping somehow shot straight at Forster.
The keeper then got up impressively to keep out Chadwick's rebound effort.
It was inevitable that if Stockport got one chance they would make Dons pay.
And they were punished when Turnbull claimed the final touch on fellow sub Tommy Rowe's dangerous whipped cross in the second minute of injury time.