Harry Forrester inflicted more last-minute misery on York as he fired Doncaster into the second round of the Capital One Cup with the only goal of the game at Bootham Crescent.
The Minstermen, who conceded an injury-time leveller at Tranmere in the league at the weekend, had laid siege to the Rovers goal in the dying embers of the game, before the visitors broke quickly with Forrester picking his spot superbly from 20 yards out - his effort going in off the left-hand post.
It was hard luck on York, with the hosts matching their League One opponents all the way.
York created the best chances in the first half, with Ryan Jarvis testing Jed Steer while Tom Platt's fizzing shot went inches wide. Doncaster's only serious effort saw Curtis Main blast over from 25 yards as they struggled to carve out any clear-cut chances.
Rovers had goalkeeper Steer to thank for keeping them in the tie as he made superb saves from Michael Coulson and Anthony Straker in the second-half.
Paul Dickov's team barely troubled Jason Mooney before Forrester's last-gasp heroics.