The visitors made the better start and Ade Akinfenwa had a shot saved in only the third minute and Chris Hackett fired over the bar three minutes later.
And only a brilliant save by Town keeper Lee Nicholls denied Kayodi Odejayi after great work by loanee Jordan Slew.
The visitors went even closer in the 21st minute when a long-range Jake Robinson effort came back off the post.
Liam Ridehalgh's effort hit the bar before the home side went ahead from the penalty spot in the 40th minute.
Ben Harding's blatant trip on Mark Bradley was immediately punished by referee Nigel Miller and leading marksman Daniel Nardiello fired home from the spot.
Rotherham should have gone further ahead in the 71st minute after a flowing move down the left but Ridehalgh's shot was just over the bar.
But two goals in three minutes put the Millers in the driving seat. After 75 minutes Ben Pringle picked up a loose ball on the edge of the area and beat Nichols with a curling low shot.
And three minutes later David Noble added the third with a powerful shot from just inside the area..
Clark Carlisle`s injury-time header was no more than a consolation for the visitors.
- Sports & Recreation
- Chris Hackett