With a couple of minutes to go and Rochdale within sight of three life-saving points, before a linesman's flag for offside led to a Doncaster Rovers equaliser.
The free-kick eventually created the chance for Mark Albrighton to fire home from close range, beating goalkeeper Neil Edwards, who looked capable of stopping everything on the night.
Edwards had saved everything that buzzing Doncaster had hurled at him, but this one was well out of his reach.
Earlier, on 72 minutes substitute, Lee McEvilly had headed Dale into the lead following a free-kick from the right and the home side almost made it 2-0 when Neil Redfearn's free-kick was saved by goalkeeper Andy Warrington only at the second attempt.
Busy Rochdale looked capable of getting a second and when they seemed home and dry that last-minute disaster came.
Early on Kevin Townson had missed a sitter when he was left one-to-one with the goalkeeper, but shot hard and straight at Warrington who managed to palm the ball over the top to rob the home side of a golden chance.
The home defence was hard pressed for long periods, but Doncaster could not get in a shot to count through a crowded penalty area and it was Rochdale, often on the break, who provided the fireworks with Leo Bertos troubling Warrington with a rocket of a free-kick and then going close in the next minute.
Grant Holt went close, but Rochdale failed to extend their lead, despite their best ts.
Late on Doncaster went all out for an equaliser and with practically the last kick of the match, substitute Adriano Rigoglioso missed a good chance of grabbing an underserved winner.