A brilliant hat-trick from on-loan striker Craig Davies fired Stockport into the play-off places.
Davies, on loan from Oldham, was clinical at Edgeley Park.
Heavy rain had taken its toll on the pitch, but both sides were playing some good football in the opening quarter of the game.
Rovers' goal machine Rickie Lambert hit a snap-shot just wide and then Craig Hinton's efforts forced Owain Fon Williams into a brilliant save.
The hosts soon found a way back into the game though, with Anthony Pilkington seeing a deflected shot just beat the far post and Davies guiding a header inches wide.
Davies made no mistake when he put the hosts in front after 27 minutes.
Tommy Rowe curled in a great cross from the left and Davies couldn't miss as he smashed home past Steve Phillips from just eight yards.
Rovers evened it five minutes before the interval. Joe Kuffour nodded down and there was Craig Disley who curled home a precise left-foot shot from 20 yards.
However, a great first-half closed with Stockport re-taking the lead in stoppage time. This time Pilkington crossed and Davies headed home clinically.
Lambert fired the first chance of the second period well over the bar for Rovers, while at the other end Johnny Mullins saw a deflected shot go wide.
With time running out, Lambert was unlucky when his volley was brilliantly beaten away by Fon Williams, before Davies wrapped up a fine individual performance with a well-taken goal in added time.
After the match, Stockport boss Jim Gannon saluted star striker Davies.
Gannon said: "They were fantastic finishes from Craig. How he didn't get the man-of-the-match award from the sponsors I don't know.
"He has shown today exactly what he is capable of. All credit to him, he deserved his goals."