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.
VIEW FROM THE DRESSING ROOM
Rotherham manager Steve Evans told BBC Radio Sheffield:
"I struggle to find the words to explain why we've not won the game, not just got something out of the game. We were the dominant side from start to finish.
"We've had to watch the theatrics that if it was us, I'd be in the stands in the second half and my players would be off the pitch.
" I don't know who the guy who got clattered was but our thoughts are with him, and if someone goes off on a stretcher, Rotherham United Football Club wants to make sure that guy goes back on the team bus and is ok."
Gillingham manager Martin Allen told BBC Radio Kent:
"We took our chances when they came their way. Everyone to a man played their part, Rotherham are the form team, and they've got some good players.
"Romain was knocked out but apparently he's breathing properly. When you see a player not moving on the football pitch and you're the manager it's horrible, but he had his eyes open when I saw him on the touchline and it was a big relief.
"I've got to say a big thank you to the Rotherham supporters who clapped him off to a man, I think he'll be ok."