Mansfield's third successive victory under new player-manager Keith Curle moved them out of the bottom four - and dragged his close friend Carlton Palmer's side into the relegation mire.
The Stags were given a helping hand, however, by Stockport keeper Lee Jones's 55th minute howler.
With the game in the balance at 2-2, the keeper somehow allowed Craig Disley's weak finish to slip through his hands and just trickle over the line.
A now rampant Mansfield then sealed their fifth home win - and each time they have scored at least four goals - when Wayne Corden curled his 20-yard drive into the bottom corner to complete the Stags' second half fightback.
County, minus the suspended Palmer, got off to the perfect start when home defender Rhys Day headed Rickie Lambert's corner into his own net.
But within three minutes the home side were level.
Corden and Liam Lawrence worked a clever short corner and Iyseden Christie headed in his 15th goal of the season, his 11th in the last nine games.
In a thrilling opening, chances continued to come thick and fast at both ends, one of them fell to Christie who sidefooted wide from six yards after another fine run by Lawrence.
County punished him by regaining the lead just 30 seconds later when Luke Beckett was fouled in the area by Curle and Ben Burgess tucked away the 16th minute penalty.
Jones denied Corden a second equaliser with a brave save at the winger's feet and, in first-half injury time Corden, blazed over an empty net.
But within three minutes of the restart Corden made amends by tucking away another penalty after Robert Clare chopped down Christie.
It was Mansfield's first successful penalty in six attempts.