Former Rotherham striker Deon Burton shrugged off boos from the Millers support to help league leaders Gillingham to a first win in four.
The 36-year-old converted Charlie Lee’s throw-in against the run of play in a first half dominated by the home side.
Burton’s solo effort extended the lead after half-time before Jason Taylor’s 18-yard shot gave Rotherham hope.
Gills held on but joy was tempered by injury to Romain Vincelot, which led to a 10-minute stoppage for treatment.
Brighton loanee Vincelot, 27, was fitted with a neck brace and withdrawn on a stretcher during the break in play after a challenge with goalscorer Taylor.
Martin Allen’s side are now five points clear of second-placed Port Vale at the top of the table and 10 points above Rotherham, who are fifth.