Richard Wood's close-range strike 13 minutes from time saw Rotherham clinch a 3-2 victory over Fleetwood, whose seven-game unbeaten run was brought to an end.
Fleetwood had won their last four matches and seemed set to extend their streak when they took the lead after only five minutes at the New York Stadium as Ashley Eastham fired past Marek Rodak at the second attempt from Ashley Hunter's corner.
Rotherham responded quickly with Joe Newell's cross being turned in by Fleetwood skipper Nathan Pond in the 12th minute. The home side dominated the rest of the first period but it took until the 51st minute for them to go in front for the first time.
Matty Palmer's header on the edge of the box fell perfectly to Newell, who volleyed beyond Fleetwood goalkeeper Alex Cairns into the bottom corner.
The goal sparked Fleetwood back into life and they equalised three minutes later through another set-piece, with Cian Bolger heading in Hunter's free-kick.
Rotherham deservedly forged back in front in the 77th minute with Wood getting enough of a connection on to Newell's cross to beat Cairns.
Michael Smith and Will Vaulks came extremely close to sealing the victory with efforts that flashed just wide.