Liam Dickinson's late penalty winner boosted Stockport's promotion hopes and heaped more pressure on desperate Mansfield.
Stockport created the first opportunity after just three minutes. Stephen Gleeson crossed for Gary Dicker, but his header was beaten away by Stags keeper Carl Muggleton.
Dickinson then raced clean through, but blasted high and wide from a promising position.
Mansfield almost went in front on 15 minutes. Matt Hamshaw swung in a curling free-kick and skipper Jake Buxton got up well to head inches wide.
The hosts were on top as the half-hour mark approached, and Dickinson's shot from the acutest of angles was smartly saved by Muggleton.
At the other end the Stags' Nathan Arnold was allowed to run through the Stockport midfield before seeing a shot saved by Powerade League Two Player of the Month for March, John Ruddy.
The match burst into life with an own goal for each side in the five minutes before half-time.
Firstly the visitors went ahead when Micky Boulding went to bundle home Hamshaw's cross, only for his effort to ricochet wildly off County midfielder Dicker.
However, Stockport were soon level when Muggleton slipped up as he punched Gleeson's in-swinging corner-kick into his own net.
The first chance of the second period came on 57 minutes when Stockport's Tommy Rowe shot wide following a surging run.
Stockport went ahead on 74 minutes. Buxton felled Tommy Rowe inside the box and was promptly red-carded by the referee, Dickinson coolly slotting home from the spot for his 18th goal of the season.