Substitute Elliott List snatched a stoppage-time equaliser to earn Gillingham a battling point from a 1-1 draw at Bristol Rovers that secured their League One status.
The 74th-minute replacement for Tom Eaves found room in a crowded penalty area to fire under diving goalkeeper Sam Slocombe in the fourth minute of added time.
Rovers had looked set to take all three points when one of their substitutes, Dom Telford, headed them in front after 86 minutes, latching onto the rebound when his initial shot was blocked.
But Gillingham never gave up and earned a share of the spoils from a drab end-of-season game.
Both sides went close in the first half. Eaves hit a post against his old club with a 26th-minute shot and Lee Martin was adjudged to be offside when netting from the rebound.
At the other end, Tom Nichols grazed an upright with a 30-yard drive after a neat turn to lose his marker and Ellis Harrison shot wide after latching onto a short back-pass from Bradley Garmston.
List’s goal was his first for The Gills in the league and proved to be crucial and they can now go into their final game of the season knowing they are safe.
Steve Lovell’s side can now entertain Plymouth Argyle next Saturday evening with the shackles off and one eye already on next season.
Bristol Rovers line up: Slocombe, Clarke, Brown, Craig, Lockyer, Sercombe, Lines, Moore (Broom 74), Bennett, Nichols (Telford 59), Harrison (Gaffney 60).
Subs not used: Smith, Broadbent, Bola, Mensah.
Goal: Telford (86).
Booked: Harrison (45+1), Bennett (52).
Gillingham line up: Holy, O’Neill, Garmston, Ehmer, Zakuani, Byrne, Reilly, Wagstaff, Martin, Parker (Wilkinson 68), Eaves (List 75).
Subs not used: Hadler, Hessenthaler, Ogilvie, Nugent, Nasseri.
Goal: List (94).
Booked: Byrne (35).
Referee: Mr Ollie Yates
Attendance: 9,715 (410 Gills)