The Millers came from a goal down to turn the game around with a dominant second half display.
Kari Arnason appeared to have headed the visitors in front when he met Ben Pringle's corner and sent a header against the underside of the crossbar. His effort appeared to have crossed the goalline, but the Millers' appeals were waved away by referee Stuart Atwell.
Rochdale goalkeeper Josh Lillis then diverted Lee Frecklington's shot over the bar as the visitors started to exert control.
But the hosts took the lead against the run of play in the 29th minute. Joe Rafferty picked out Ashley Grimes and the in-form striker sent a half volley wide of Andy Warrington, his fifth goal in the last six games.
Rotherham dominated the second period and deservedly levelled in the 78th minute when Kayode Odejayi collected Courtney Cameron's corner and scrambled the ball home from six yards after Alex Revell's knock down.
Odejayi was involved in the winning goal too, his run into the Dale area ended by Kevin McIntyre whose slide tackle presented the ball to Cameron who curled home the winner in stoppage time.