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."
Live Text Commentary
Full Time The match has reached full-time.90:00 +10:53
Lee Frecklington takes a shot. Matt Fish gets a block in. Corner from left by-line taken by Ben Pringle.90:00 +9:33
Lewis Montrose gives away a free kick for an unfair challenge on Kayode Odejayi. The free kick is delivered left-footed by Ben Pringle from left wing, Matt Fish makes a clearance.90:00 +6:56
Free kick awarded for an unfair challenge on Lewis Montrose by Kayode Odejayi. Stuart Nelson takes the direct free kick.90:00 +6:01
Outswinging corner taken by Ben Pringle from the left by-line, Andy Frampton makes a clearance.90:00 +5:22 Booking
Booking Charlie Lee goes into the book for time wasting.90:00 +4:17
Free kick awarded for an unfair challenge on Jack O'Connell by Myles Weston. Free kick crossed left-footed by Ben Pringle from left wing, save by Stuart Nelson.90:00 +3:02
Free kick awarded for an unfair challenge on Bradley Dack by Lee Frecklington. Danny Kedwell takes the free kick.90:00 +3:02 Booking
Booking The referee cautions Stuart Nelson for time wasting.90:00 +2:17
Foul by Charlie Lee on Lee Frecklington, free kick awarded. Kari Arnason takes the direct free kick.90:00 +1:24
Myles Weston produces a left-footed shot from the edge of the box and misses to the left of the target.90:00 +0:20
Kayode Odejayi is flagged offside by the assistant referee. Stuart Nelson takes the free kick.88:35 Substitution
Substitution (Rotherham) makes a substitution, with Kayode Odejayi coming on for Daniel Nardiello.88:35
Alex Revell takes a shot.87:59
Short corner taken by Ben Pringle from the left by-line.84:36 Booking
Booking Matt Fish receives a yellow card.84:25
Courtney Cameron fouled by Matt Fish, the ref awards a free kick. Ben Pringle takes the direct free kick.75:00 Booking
Booking The referee books Jason Taylor for unsporting behaviour.74:45
Stuart Nelson restarts play with the free kick.74:45 Substitution
Substitution Romain Vincelot leaves the field to be replaced by Bradley Dack.
Jason Taylor concedes a free kick for a foul on Romain Vincelot.72:25
Joe Martin gives away a free kick for an unfair challenge on Ben Pringle. Ben Pringle sends in a cross, Headed effort from deep inside the penalty area by Daniel Nardiello misses to the left of the goal.69:59 Substitution
Substitution Deon Burton goes off and Myles Weston comes on.69:59 Substitution
Substitution Lewis Montrose replaces Jack Payne.68:22 Goal scored
Goal! - Jason Taylor - Rotherham 1 - 2 Gillingham Jason Taylor finds the net with a goal from long distance to the top left corner of the goal. Rotherham 1-2 Gillingham.67:20
Free kick taken by Jason Taylor. Outswinging corner taken left-footed by Ben Pringle played to the near post, Deon Burton manages to make a clearance.67:20 Booking
Booking Booking for Charlie Allen for dissent.67:07
Charlie Lee gives away a free kick for an unfair challenge on Ben Pringle.66:11
A cross is delivered by Liam Ridehalgh, Alex Revell takes a shot. Corner taken left-footed by Ben Pringle, Matt Fish manages to make a clearance.64:14
Jason Taylor takes a shot. Blocked by Matt Fish.62:57 Substitution
Substitution Courtney Cameron replaces Michael O'Connor.60:39
Jason Taylor takes a shot. Save made by Stuart Nelson. Ben Pringle takes the inswinging corner, clearance made by Charlie Lee. Corner taken by Ben Pringle played to the near post, clearance by Charlie Lee.60:04
Corner taken by Ben Pringle from the right by-line to the near post, clearance by Charlie Lee.59:46
Inswinging corner taken by Michael O'Connor, clearance made by Deon Burton.57:27
Adam Barrett gives away a free kick for an unfair challenge on Kari Arnason. Andy Warrington takes the direct free kick.56:08
Assist by Romain Vincelot.56:08 Goal scored
Goal! - Deon Burton - Rotherham 0 - 2 Gillingham Deon Burton finds the net with a goal from inside the box to the bottom right corner of the goal. Rotherham 0-2 Gillingham.54:26
Effort from outside the penalty box by Charlie Lee goes wide left of the target.53:36
The assistant referee flags for offside against Daniel Nardiello. Stuart Nelson restarts play with the free kick.52:19
Outswinging corner taken by Joe Martin from the left by-line, Alex Revell makes a clearance.51:48
Lee Frecklington takes a shot. Save made by Stuart Nelson.49:47
Daniel Nardiello produces a right-footed shot from just outside the penalty area that goes harmlessly over the target.46:39
Unfair challenge on Johnny Mullins by Romain Vincelot results in a free kick. Free kick taken by Ben Pringle.45:01
The referee gets the second half underway.45:00 +4:47 Half time
Half Time The match has reached half-time.45:00 +2:35
Outswinging corner taken from the left by-line by Joe Martin.45:00 +0:11
Inswinging corner taken from the right by-line by Ben Pringle, Matt Fish makes a clearance. Corner taken right-footed by Michael O'Connor, Alex Revell produces a header from inside the area that goes over the crossbar.44:08
Jack Payne produces a right-footed shot from deep inside the six-yard box which goes wide of the right-hand upright.43:22
The referee blows for offside against Daniel Nardiello. Free kick taken by Stuart Nelson.39:48
Free kick awarded for a foul by Charlie Allen on Michael O'Connor. Direct free kick taken by Andy Warrington.38:24
Corner taken right-footed by Michael O'Connor, Matt Fish manages to make a clearance.37:02 Booking
Booking Deon Burton goes into the referee's book.35:17
The assistant referee signals for offside against Danny Kedwell. Andy Warrington takes the indirect free kick.33:57
Daniel Nardiello produces a left-footed shot from deep inside the area which goes wide of the left-hand post.32:51
Ben Pringle fouled by Deon Burton, the ref awards a free kick. Liam Ridehalgh takes the free kick.28:55
Matt Fish challenges Daniel Nardiello unfairly and gives away a free kick. Direct free kick taken by Michael O'Connor.26:19
Jason Taylor takes a shot. Save by Stuart Nelson. Inswinging corner taken left-footed by Ben Pringle, save by Stuart Nelson.23:30
The referee blows for offside. Free kick taken by Andy Warrington.20:43
Andy Frampton concedes a free kick for a foul on Alex Revell. Direct free kick taken by Jason Taylor.20:00
Joe Martin produces a cross, save by Andy Warrington.19:22
Charlie Allen takes the outswinging corner, clearance by Jason Taylor.17:51
Free kick awarded for a foul by Adam Barrett on Alex Revell. Michael O'Connor produces a shot on goal direct from the free kick, Stuart Nelson makes a save.17:05 Substitution
Substitution Jack O'Connell replaces Ian Sharps.15:09
Deon Burton gives away a free kick for an unfair challenge on Ian Sharps. Free kick taken by Andy Warrington.13:51
Kari Arnason has an effort at goal and missed to the left of the target.13:13
Inswinging corner taken by Michael O'Connor from the left by-line, Charlie Lee makes a clearance.12:32
Foul by Charlie Allen on Jason Taylor, free kick awarded. Andy Warrington restarts play with the free kick.10:56
The assist for the goal came from Charlie Lee.10:56 Goal scored
Goal! - Deon Burton - Rotherham 0 - 1 Gillingham Deon Burton grabs a goal from inside the six-yard box to the bottom left corner of the goal. Rotherham 0-1 Gillingham.8:26
Deon Burton is ruled offside. Indirect free kick taken by Andy Warrington.7:20
Inswinging corner taken by Michael O'Connor, Alex Revell concedes a free kick for a foul on Charlie Lee. Stuart Nelson takes the free kick.3:39
Andy Frampton concedes a free kick for a foul on Alex Revell. Kari Arnason takes the direct free kick.1:15
Michael O'Connor concedes a free kick for a foul on Romain Vincelot. Direct free kick taken by Stuart Nelson.0:08
Danny Kedwell challenges Johnny Mullins unfairly and gives away a free kick. Direct free kick taken by Andy Warrington.0:00
The referee starts the match.
Live data and text provided by our data suppliers