Jeff Hughes put the League Two side ahead after 19 minutes. Nathan Tyson's persistence paid off as he tumbled in the box, and Hughes scuffed his shot through the legs of Adam Collin.
The Millers dominated the first half but grim determination kept them at bay.
But the dam finally broke 10 minutes after the break. Kieran Agard had already hit a post and on his next foray forward the striker's shot was blocked by Mark Roberts and Nouha Dicko, following in at the back post, fired Rotherham level.
The goal injected fresh life into Fleetwood, with Antoni Sarcevic nearly forcing a way through.
Indeed, 18 minutes from time they found a second as Matty Blair's run was cut short by Ben Pringle and McLaughlin hit a stunning 25-yard curler.
There was late drama as first Lee Frecklington and then James Tavernier forced added-time saves from Scott Davies as Fleetwood held on.