John Egan, Brennan Dickenson and Luke Norris scored late on as the Gills came from behind to beat Notts County 3-1 and relegate England's oldest club at the MEMS Priestfield Stadium.
After Graham Burke had seemingly earned County another season in League One, the trio provided some brilliant late drama to ensure the Gills took all three points and placed 12th in the final table.
Manager Justin Edinburgh warned County before this fixture not to expect a helping hand in their survival bid, and he confirmed this by fielding a strong team. Edinburgh made three changes from the 11 who lost last Saturday at Scunthorpe, as Bradley Dack
, Aaron Morris and John Marquis came in for Oliver Muldoon, Jake Hessenthaler
Marquis was involved in the game's first chance, as he played in Cody McDonald
following a quick Gills breakaway in the fifth minute. McDonald cut inside and shot low, but was denied by County goalkeeper Roy Carroll.
Morris had a volley well blocked by County captain Hayden Mullins in the 12th minute, and then Carroll rushed off his line to prevent McDonald latching onto Leon Legge
's lofted through ball seconds later.
McDonald threatened again on 17 minutes, as Haydn Hollis produced a vital block to deny him a volleyed opener.
But against the run of play, County should have taken the lead in the 19th minute. From a quick break, Balint Bajner played in Garry Thompson, whose shot was brilliantly tipped over by Glenn Morris. From the resulting corner, Graham Burke produced a powerful effort that Morris was equal to.
Dack then came close on three occasions in as many minutes to opening the scoring. First, he had a effort cleared off the line by Gary Jones after round Carroll, and then headed at the County goalkeeper from a corner after Marquis's low effort was parried wide.
Carroll then had to again rush out to stop McDonald racing through on goal, from which Dack shot inches wide from 30 yards.
In a repeat of what happened earlier in the half, only a brilliant Morris double-save prevented County from going in front against the run of play. He denied Hollis and Jimmy Spencer – the first from a header, the second from the rebound following a County corner.
And the half ended with Morris again in the action, as he saved Spencer's low shot on the turn.
The second half initially lacked the excitement of the first, and after both teams created little more than half chances in the opening third of it, the visitors went ahead through Burke in the 61st minute. Played through by Liam Noble, Morris got a hand to his effort but was unable to keep it out.
Noble threatened from 20 yards minutes later, as the away fans chanted confidently about their team's survival hopes.
They needn't have worried about Marquis's free-kick in the 80th minute, which he blazed over, although Doug Loft's speculative long-range effort five minutes from time was closer.
But with time running out, Egan headed in at the back post from Loft's deep cross to level the tie – and the Gills weren't finished there.
Dickenson curled in a brilliant second in stoppage time, before Norris scored his first goal at Priestfield with a fine solo effort to put the result beyond doubt and send the visitors down.
Gillingham: G Morris, Egan, Legge, Ehmer, McGlashan, Dack, A Morris (Norris 70), Loft, Dickenson, McDonald (Freiter 90), Marquis.
Subs: Nelson, Hoyte, Hessenthaler, Muldoon, Pritchard
Notts County: Carroll, Williams, Hollis, Mullins (Lita 90), Adams, Burke (McCourt 72), Jones, Noble, G Thompson, Spencer (Dumbuya 81), Bajner.
Unused subs: Pilkington, Hayhurst, C Thompson, Edwards.
Attendance: 8, 443 (2, 058 Notts County)
Referee: Mr S Attwell