Newport County and Cameron Antwi were left stunned in dramatic fashion as Gillingham struck twice deep into stoppage time to snatch victory at the MEMS Priestfield Stadium.
Goals from Michael Spellman and Antwi had put Newport County in a strong position, but a late penalty from Armani Little and a stoppage-time header from substitute Gareth McCleary turned the contest on its head.
Head coach Christian Fuchs named a much-changed side featuring several January additions, with Ryan Devaney making a second debut, Harris Biggins handed a first start, and Liam Shephard also returning to the line-up. Nathan Opoku led the attack after extending his loan from Leicester City.
Newport County made a flying start and took the lead after just four minutes. A Gillingham clearance from a set piece fell kindly for Spellman, who reacted quickest to turn the ball home from close range.
The visitors remained on top in the opening stages, with Jordan Wright called into action to deny Josh Andrews and Jonny Williams as Gillingham responded.
The hosts levelled on 30 minutes when Conor Masterson powered a header into the far corner from a Max Clark delivery.
Gillingham then applied sustained pressure before half-time, but Wright produced key saves to keep Newport County in the game, including a superb stop from Andrews.
The visitors looked dangerous on the counter, with Bobby Kamwa and Harris Biggins both involved in promising moments before the break.
Newport County regained the lead on 83 minutes. Devaney won possession high up the pitch and released substitute Tanatswa Nyakuhwa, whose delivery was controlled by Antwi before he turned and finished low past Glenn Morris.
However, the game turned dramatically during a long period of stoppage time. After Nyakuhwa was penalised for a challenge inside the area, Armani Little converted the resulting penalty to make it 2-2.
Deep into added time, Gillingham completed the comeback when McCleary rose highest in the box to head home and secure all three points for the hosts.
Newport County pushed until the end, with substitute James Crole denied at close range by a fine save from Glenn Morris, but were unable to find a second equaliser.
Gillingham
Glenn Morris; Conor Masterson (Gareth McCleary 70), Sam Gale, Andy Smith, Max Clark; Armani Little (captain), Robbie McKenzie (Ethan Coleman 102), Jonny Williams (Remeao Hutton 86), Aaron Rowe, Bradley Dack (Ethan Coleman 102), Josh Andrews (Sam Vokes 87)
Substitutes (unused): Jake Turner, Seb Palmer-Houlden, Elliott Nevitt
Newport County
Jordan Wright; Liam Shephard (Joe Thomas 88), Lee Jenkins (Ciaran Brennan 76), Matt Baker (captain), Ryan Devaney; Anthony Glennon, Mark Smith, Harrison Biggins, Michael Spellman (Tanatswa Nyakuhwa 55); Bobby Kamwa, Nathan Opoku (James Crole 89)
Substitutes (unused): Nik Tzanev, Tom Davies, Cameron Antwi
Match officials
Referee | Carl Brook
Assistants | Danny Guest, Bradley Hall
Fourth official | Anthony Moore
Attendance
5,548 (166 away supporters)