Luke Chambers thumped home the winner four minutes from time to leave Town only out of the Play-Offs on goal difference.
The Blues’ skipper latched on to the loose ball inside the Doncaster box and gave Sam Johnstone no chance with a right foot finish into the bottom corner.
Daryl Murphy’s 13th goal of the season had edged Town in front early in the second-half but Tyrone Mings’ foul on Mark Duffy handed Rovers a penalty on 83 minutes and Chris Brown levelled from the spot.
It looked enough to give Doncaster a point until Chambers struck to leave Blues in seventh and right in the shake-up for the Play-Offs with four games left.
Town made one change from the team that beat Huddersfield in midweek, Aaron Cresswell failing to shake off the groin injury that forced him off in that 2-0 win, Mings the replacement in Blues’ first change to the backline in a Championship game since November.
Billy Sharp, a target of Town’s two years ago, almost threatened an early breakthrough for the visitors, Tommy Smith hooking the ball away from danger as the Rovers striker prepared to shoot.
Stephen Hunt’s direct run at the Doncaster defence saw the ball break to Luke Hyam but he couldn’t keep his shot down.
Mings forced Johnstone into a good save low down to his left with a terrific strike, then both Doncaster strikers received yellow cards in quick succession, Brown for a foul on Cole Skuse, Sharp for a challenge on Jonny Williams.
Hunt was so close to putting Town ahead on 20 minutes, the Republic of Ireland international launching himself at Paul Anderson’s brilliant cross but diverting the ball just wide of the post.
Brown was then denied by Dean Gerken from close range after the striker contrived a shot out of nothing from Jimmy Husband’s cross, while at the other end Luke Chambers’ delivery was headed over by Daryl Murphy.
Gabriel Tamas forced Gerken into an acrobatic save with a free header from a corner, Smith then heading David Cotterill’s cross over his own bar as Donny continued to carry a threat.
Christophe Berra was yellow carded for a foul on Brown, Hunt then finding Chambers in the box but his header was wide before the half came to an end with a fantastic save from Johnstone keeping out Smith’s header.
Town made a double change with Frank Nouble and Sylvan Ebanks-Blake on for Hunt and Anderson at the break and within a minute of the restart, Town were in front, Mings’ cross headed in by Murphy.
Nouble, ever the willing runner, forced Johnstone to hurry his clearance from the edge of the box, Tamas then stretching to slice Murphy’s cross over his own bar.
Ebanks-Blake curled one just wide after Williams had won the ball deep in the Doncaster half, then the ball slipped through Berra’s legs 18 yards out from a corner when the Scotland international would have fancied his chances of a shot at goal.
Tamas whipped in a cross that evaded Brown as the game reached the last 15 minutes, Williams then winning a free-kick on the edge of the box but Cole Skuse’s strike was high and wide.
Duffy replaced Dean Furman in Rovers’ first change, Husband wasting a free-kick from a promising position, the full-back sustaining an injury taking the set-piece with Enda Stevens his replacement.
Doncaster’s equaliser came seven minutes from time and out of nothing, Mings catching Duffy in the box as they challenged for a throw, referee Graham Scott pointing to the spot and Brown doing the rest.
Mings didn’t take long to make up for his error though, the full-back forcing his way deep into Doncaster territory as the visitors looked for a foul on Tamas and when the ball broke to Chambers he thumped a right foot strike into the bottom
Brown could – and perhaps should have grabbed an equaliser for Doncaster, his header going straight at Gerken from six yards out and the ‘keeper had to hold firm as Rovers pressed.
Nouble could have given Town breathing space with virtually the last kick, Johnstone equal to the task though as Blues picked up three big points.