Rotherham moved in to the League One play-off zone after their dominant first-half display lay the foundations for victory against Gillingham.
Nouha Dicko fired in after controlling Alex Revell's header while Kieran Agard finished well for the Millers' second.
Ben Pringle's superb solo effort saw Rotherham 3-0 up after just 35 minutes.
Gillingham scored when Cody McDonald converted Adebayo Akinfenwa's pass, but James Tavernier restored the three-goal cushion with a clinical finish.
VIEW FROM THE DRESSING ROOM
Gillingham manager Peter Taylor Told BBC Radio Kent:
"First half, Rotherham were miles better than us. They deserved to be at least 3-0 up - it was a very poor start.
"We have to learn from things like that. We were lucky it was only three [at half-time].
"It was nice to get a goal back but as much as you'd love to get it back after the first half, we'd have had to score exceptionally quickly.
"It was not a good day. I can't tell any lies. No excuses."
Rotherham United 21 Collin 27 Tavernier 03 Skarz (Brindley - 38' ) 23 Tidser (Tubbs - 88' ) 04 Arnason 20 Morgan 22 Agard 08 Frecklington 09 Revell (Vuckic - 83' ) 26 Dicko 18 Pringle Substitutes 01 Shearer 02 Brindley 05 Davis 06 Mills 16 Tubbs 28 Vuckic Gillingham 01 Nelson 23 Harriman 03 Martin 19 Hollands 26 Barrett 28 Daniels 07 Whelpdale (Hessenthaler - 85' ) 32 Mousinho (Weston - 25' ) 10 McDonald 09 Kedwell (Akinfenwa - 64' ) 18 Lee Substitutes 05 Davies 08 Akinfenwa 11 Weston 15 Dack 20 Carter 21 Howard 31 Hessenthaler
Ref: Andy Woolmer