Gillingham produced one of their best performances of the season to beat league leaders Swindon Town 3-1 at the MEMS Priestfield Stadium with Chris Whelpdale scoring twice in the process.
A Danny Kedwell header put the hosts ahead with Whelpdale doubling the advantage shortly into the second half.
An Alan McCormack strike gave the fans a nervous 10 minutes or so, but a spot kick from the midfielder deep in to stoppage time sealed the points.
The Gills were well aware that any result other than a win would all but end their chances of obtaining a play-off position, and Andy Hessenthaler chose to make two changes to the team that drew against Oxford last time out.
Danny Jackman and Charlie Lee returned in place of Rowan Vine and the injured Gavin Tomlin.
Swindon made eight alterations to their team - former Gills winger Luke Rooney wasn't included in the match squad.
Both sides started well with Swindon perhaps having more of the possession in the opening minutes.
The Gills certainly looked stronger in the middle of the park with the returning Charlie Lee trying to boss things from the right hand side.
The first chance of the game wasn't created until the 12th minute though - a free kick was awarded to Swindon 25 yards out and the ball was played to John Bostock whose left foot strike could only find the side netting.
The reason for Swindon being top of the league was quickly becoming evident as the half progressed.
Their quick, incisive style of play began to stretch the Gills defence and they certainly had the better of things during the first quarter of an hour.
However the Gills began to exert some pressure of their own and on 26 minutes they took the lead.
A Lee throw found Danny Kedwell in the box, and his looping header made its way over the head of Phil Smith and into the back of the net.
It was a clever piece of improvisation from the forward who claimed his 14th goal of the season in all competitions in the process, and gave the home side the momentum they were looking for.
A couple of minutes later and Alan Connell should have brought the scores level - he picked up the ball inside the box and shifted his weight to the left hand side and struck across Paulo Gazzaniga.
However the Argentine was alert to the effort and got down quickly to claim the ball as the visitors continued to press forward.
Like the Oxford game the defence were in no mood to relinquish their clean sheet and they could possibly have had a two goal advantage to defend at the break.
Matt Fish burst forward and with the help of a couple of ricochets made his way to the 18-yard line and unleashed a left foot effort which Smith dealt with comfortably.
With 44 minutes on the clock Lewis Montrose and Chris Whelpdale went nail-bitingly close within just seconds of each other.
Firstly Montrose struck the bar with venom with a 20-yard effort with the keeper well beaten, and then Whelpdale rose highest to guide a header goalwards, but to the relief of the Swindon fans it nestled the top of the net and away for a goal kick.
Seven minutes in to the half and the lead was eventually doubled. Whelpdale, who went close before the break, tried his luck with a left foot chip which caught Smith off guard and he could only watch the ball go past him and nestle in the top corner.
It was a delightful effort from the midfielder who was hassled all the way down the left touchline, but he spotted an opportunity and converted beautifully to give the Gills a deserved 2-0 lead.
On 57 minutes Gazzaniga had to improvise as a free kick was deflected on its way towards goal.
Ritchie stepped up and having struck the ball the keeper seemed to stop as the ball got closer, and using his legs managed to get the ball away for a corner which came to nothing.
At the other end just seconds later Whelpdale should have had a second - having found a yard of space in the penalty area he attempted to give Smith the eyes and went for a near post effort which struck the foot of the post and away from danger.
The game was far from dull and both sides were now in full flow - the Gills doing their utmost to extend the lead and Swindon wanting to half the deficit.
The visitors claimed for a penalty in the 60th minute via Joe Martin's unintentional handball before Jo Kuffour wasted a chance at the other end to play in Whelpdale.
He had plenty of time and options either side of him but went himself and eventually tripped - Andy Hessenthaler was far from impressed in the dugout.
A midfield battle then ensued as both sets of players tried to command things in the middle, however on the occasions that Swindon did get through they found Frampton and Essam in fantastic form.
On 81 minutes the visitors did pull one back. Alan McCormack ran through on goal unchallenged and with his right foot placed a great shot beyond Gazzaniga who could do nothing to prevent the goal.
This set up a nervy last ten minutes as the home side did everything they could to hold on to their slender lead. Substitute Ronan Murray - on for Alan Connell - went close at the near post as Paulo di Canio's team attempted to celebrate promotion with at least a point.
In the last minute another attempt by Whelpdale was kept out by Smith - the midfielder tried to place in the bottom left hand corner but the keeper got down quickly and palmed his effort clear for a corner.
Five minutes of additional time was awarded and with just seconds to play the hosts were awarded a penalty.
Curtis Weston went over after being tripped just inside the area, and with Kedwell having gone off; the responsibility fell to Whelpdale who converted calmly to give victory to Gillingham with the final whistle following immediately.
Gills: Gazzaniga, Fish, Essam, Frampton, Martin, Whelpdale, Montrose, C Lee (Spiller 71), Jackman, Kuffour (Vine 74), Kedwell (Weston 83).
Unused subs: King, Oli.
Swindon: Smith, Caddis, McEveley, Flint, McCormack, Ferry, Risser (Smith 52), Ritchie, Bostock, Holmes (Gabilondo 72), Connell (Murray 37).
Unused subs: Thompson, Scott.
Referee: Mr S Rushton
Attendance: 6,390 (1245 Swindon)
Bookings: Frampton (11), Kedwell (34), Jackman (57), Essam (87)
Goals: Kedwell (26), Whelpdale (52 & 90), McCormack (81).