Doncaster's Paul Heffernan struck twice to plunge Rotherham deep into trouble.
Richie Partridge put Rotherham ahead after only 10 minutes with a superb volley, but Heffernan headed an equaliser two minutes later.
Graeme Lee headed Doncaster in front from Brian Stock's corner after 47 minutes and Heffernan fired home the third just on the hour.
Martin Woods scored a spectacular goal against the run of play in the 71st minute, but Doncaster deserved the win.
Doncaster: Smith, O'Connor, Lockwood, Lee, Gilbert, Coppinger (Wilson 90), Stock, Paul Green, Forte (Guy 90), Heffernan, Price (Stephen Roberts 87).
Subs Not Used: Gareth Roberts, Thornton.
Goals: Heffernan 12, Lee 47, Heffernan 59.
Rotherham: Cutler, Worrell, Mills, Sharps, Brogan, Partridge (Newsham 69), Diagouraga, Bopp, Woods, O'Grady, Facey.
Subs Not Used: Montgomery, Wiseman, King, Yates.
Booked: Diagouraga, Brogan.
Goals: Partridge 10, Woods 71.
Ref: P Taylor (Hertfordshire).