Deon Burton returned to haunt former club Rotherham with a goal either side of half-time to earn Gillingham a 2-1 win at the New York Stadium.
Rotherham had the majority of play and possession in an often ill-tempered first half, but it was the visitors who managed the only goal.
A long throw after 11 minutes was back headed into the area by Danny Kedwell and Burton on hand to stab it home.
Shortly afterwards Rotherham lost skipper Ian Sharps to injury following a challenge by Burton, but the home side still made all the running.
Michael O'Connor rounded Stuart Nelson after a great solo run but could not turn the ball home from an acute angle, before Jason Taylor saw his 27th minute shot tipped over by the Gills goalkeeper
But 12 minutes after the break Burton did it again. Picked out on the edge of the box, he held off the challenge of his marker before firing past Andy Warrington.
It was the signal for an all out Rotherham onslaught. Nelson made a great save to deny Alex Revell before substitute Courtney Cameron rolled a pass across the edge of the area to Taylor, who drilled the ball home after 69 minutes.
The game was then halted by an injury to Romain Vincelot who went down under a challenge from Taylor, a challenge that earned him a booking and a huge 11 minutes of injury time.