Two stoppage-time goals clinched victory for Gillingham on the final day of the season.
Graham Burke’s goal on the hour for Notts County looked to be enough for them to avoid relegation.
But a headed goal from John Egan, with two minutes left, levelled the scores.
Gills then won it with goals from Brennan Dickenson and Luke Norris in injury-time, to send County down to League 2.
Gillingham finished the season in 12th place.
Justin Edinburgh said pre-match that he would name a strong team for a match that visitors Notts County needed to win, in order to guarantee their League 1 survival.
Out went Jake Hessenthaler, Oliver Muldoon and Luke Norris from the starting XI.
On-loan Millwall striker John Marquis returned to the Gills front-line in what could be his last game for the club. Bradley Dack and Aaron Morris were also back to start.
Marquis wasn’t the only one possibly leaving following Sunday’s clash. Leon Legge and Glenn Morris are awaiting news on whether they are wanted for another season. Defender Max Ehmer is expected to be back with Championship-bound QPR in the summer.
County were backed by over 2,000 supporters as they chased victory for a place in League 1 next season. They started the day clear of the relegation places on goal difference.
There was no shortage of chances for either team in the opening half, with six on-target shots each. The only surprise was the lack of goals.
Gills keeper Morris pulled off a series of good blocks to thwart County, who looked good in spells, but were largely kept on the back-foot by Edinburgh’s men.
Dack had a shot stopped on the line by Gary Jones, sent another narrowly wide from 30 yards and headed into the keeper’s arms. Marquis also had a lively first half, drawing a good save from Roy Carroll as he fired towards the bottom corner.
By the interval results elsewhere had seen County slip into the bottom four. The large travelling contingent had struggled to find their voice in the opening half; no doubt nervous of what was happening at Priestfield and elsewhere.
Doug Loft and Dack sent efforts wide for the Gills in the second half before the visitors struck.
County got a lifeline with a 61 minute goal when Graham Burke drilled home a shot from an angle, after a ball from Liam Noble. Morris got a hand to the shot but it had too much power.
Gillingham switched to 4-3-3 for the final 20 minutes as striker Norris replaced Aaron Morris.
Marquis’ 80 minute free-kick went well over for the Gills, whose shooting was well adrift in the second 45 minutes.
With two minutes left the Gills levelled the game as Egan powered home Loft’s cross and in stoppage-time as Notts County struggled to clear, Dickenson smashed the ball home to put the hosts ahead.
Dickenson then turned provider moments later, as the Gills burst forward, laying off the ball for Norris to fire home a third.
Gillingham: G Morris, Egan, Ehmer, Legge, Loft, A Morris (Norris 70mins), Dickenson, Dack, McGlashan, Marquis, McDonald (Freiter 90mins). Subs not used: Nelson, Hessenthaler, Muldoon, Pritchard, Hoyte.
Notts County: Carroll, Adams, Mullins (Lita 90mins), Hollis, Spencer (Dumbaya 81mins), G Thompson, Jones, Noble, Burke (McCourt 72mins), Bajner, Williams. Subs not used: Pilkington, Wayhurst, C Thompson, Edwards.
Attendance: 8,443 (2,058 away)