Brian Stock's spot-kick had put the visitors ahead in the 77th minute but Antoine Sibierski equalised with a superb header six minutes later and Leroy Lita stabbed home the winning goal in stoppage time.
The visitors kicked off attacking the River End goal, but it was the home side who created the first shooting chance. Lee Croft broke into the Doncaster penalty area from the right wing, but elected to pass and Darel Russell failed to make contact with the ball.
Sammy Clingan's free-kick cleared the crossbar and the game then entered a stalemate phase with neither side able to create a clear chance until the 23rd minute when another shot from Clingan landed on the roof of the net.
As if to relieve the boredom the referee booked Clingan for a fairly innocuous challenge and Gareth Roberts likewise.
In first-half stoppage time Jason Price followed them into the book for kicking the ball away to delay a City free-kick.
In the first minute of the second half Clingan put in an excellent right-wing cross, but no City player reacted quickly enough to take advantage.
Lita then pulled the ball back to strike partner, Sibierski, but Neil Sullivan blocked his snap-shot and the ball was cleared.
Price brought a save from David Marshall as the visitors became more adventurous.
The penalty was awarded by the assistant referee when Price stumbled over in a tangle with Dejan Stefanovic and Stock sent Marshall the wrong way with his spot-kick.
The equaliser came in the 83rd minute when Clingan's shot fell to Sibierski and he reacted quickly to send a looping header over Sullivan beating the veteran keeper to his left.
Sibierski then played a part in the winner when he headed on a long ball from Stefanovic and Lita's right-foot shot from 12 yards went through Sullivan's legs to send the home fans into rapturous applause.