The home side, who lost to play-off hopefuls Shrewsbury on Saturday, had the better early chances at the Don Valley Stadium and went in front just before the break.
Ian Sharps slipped a neat ball to Dale Tonge and he swung in a textbook cross for young striker Ryan Taylor who produced a towering header that gave keeper Barry Roche no chance.
Early in the second half Rotherham might have added another but Nick Fenton’s header hit the crossbar.
Moments later the visitors were level when Rene Howe sent in a super pass from the left and Diarmuid O’Carroll clipped an accurate shot past Andy Warrington.
Ten minutes from the end Rotherham sparked a late flurry when sub Jason Taylor restored their advantage after a cross Jamie Green.
Substitute Mark Burchill clinched the points with a late penalty after Jim Bentley handled in the area, before the Shrimps defender pulled one back with an injury-time volley.