Gillingham’s season ended much as the past few weeks have gone with defeat and missing out on a play-off place.
Results elsewhere and a run of eight games without a win condemned Gillingham to ninth in League One while Millwall will travel to Bradford in the play-offs following Lee Gregory’s 98th minute penalty.
The opening exchanges saw little goalmouth action but Stuart Nelson kept the scores level on 22 minutes with a spectacular double save, first from Aiden O’Brien, and then tipping Joe Martin’s point-blank range shot onto the crossbar.
The deadlock was broken on 55 minutes as, despite Nelson’s initial save from Steve Morison’s close-range shot, O’Brien slotted in the rebound.
The Lions looked the likelier side to score and had a golden chance when Morison headed onto the upright on 75 minutes.
But the game reached boiling point late on when former Gills defender Mahlon Romeo was sent off for a late challenge on Brennan Dickenson.
A goal just into stoppage time from John Egan gave the Gills a late boost, but the crowd was silenced eight minutes into time added on when Gregory slotted home from the penalty spot after being pulled down by Dickenson.
With Barnsley, Scunthorpe United and Coventry City having all won, The Gills drop down to ninth in the table with the former claiming the last play-off place.
Gillingham line up: Nelson, Oshilaja, Egan, Ehmer, Dickenson, Wright, Hessenthaler (Jackson 58), Loft (Williams 58), Dack, McDonald, Samuel (Norris 59).
Subs not used: G Morris, El-Abd, Osadebe, Donnelly.
Goal: Egan (92).
Booked: Dack (79).
Millwall line up: Archer; Romeo, Webster, Beevers, Martin; Taylor, Abdou, Thompson, Ferguson (Upson 71); O’Brien (Gregory 75), Morison (Craig 88)
Subs not used: Forde, Edwards, Williams, Onyedinma.
Goals: O’Brien (55), Gregory (pen 98).
Booked: Archer (92), Taylor (95).
Sent Off: Romeo (86).
Referee: Mr Paul Tierney
Attendance: 9,375 (1,213 Millwall)