Gillingham remain threatened with relegation after suffering a home defeat on Saturday.
Fleetwood won the match in stoppage-time and the Gills will now be hoping relegation rivals Port Vale drop points in midweek, to ensure they will be playing League 1 football next season.
Defeat was greeted by boos at the final whistle by angry home fans.
The Gills were ahead at the break, as keeper Alex Cairns turned in Zesh Rehman’s header.
The visitors levelled in the second half through Ashley Hunter but a deflected Rory Donnelly free-kick put the Gills back infront. David Ball made it all-square again and Kyle Dempsey won it in stoppage time.
Gillingham finish the day four points above Port Vale, who play their game in hand on Tuesday night at Walsall.
There were three changes to Gills’ starting XI, two of which were enforced. Suspension sidelined Bradley Dack, Joe Quigley was ruled out with injury while Harry Cornick was dropped to the bench.
Rory Donnelly came into the attack, Rehman returned into central defence and Josh Parker took up an unfamiliar left-sided wing-back position.
Gillingham knew a win would all-but secure their League 1 safety. Fleetwood needed points to keep alive their hopes of automatic promotion.
The game took some time to kick into life, with Parker twice coming close for the Gills in the opening half hour.
Fleetwood looked anything-but promotion challengers but did come close themselves, with Amari’i Bell testing Tomas Holy with a shot from a short corner. The Gills man got down well to save at his near post.
The Gills took the lead in the 38 minute from a Martin corner. Rehman’s headed effort hit the post but then went in off unfortunate keeper Cairns.
It was the start of a flurry of chances for the Gills, with Martin fizzing several good balls into the box. Cody McDonald headed one of those over as the Gills held onto their 1-0 advantage by the break.
The scores were level again nine minutes into the second half. David Ball flicked on to Hunter and he drove the ball home with Holy left flat-footed in the Gills goal.
Holy was beaten again with just over an hour gone, as Fleetwood break, but Bobby Grant’s shot bounced to safety off the far post. Moments later the Gills were back infront.
Donnelly fired in the free-kick and the ball was taken past keeper Cairns thanks to a ricochet off the foot of David Ball, putting the Gills 2-1 ahead with 65 minutes gone.
Jake Hessenthaler almost scored a spectacular third for the Gills, crashing a 20 yard volley off the upright.
Fleetwood were back level with 10 minutes left as Ball guided Cian Bolger’s flick past Holy and they won it in time added on when Dempsey struck low in the 92 minute.
Gillingham: Holy, Jackson, Ehmer, Oshilaja, Rehman, Martin (Osadebe 81mins), Wright, Hessenthaler, Donnelly (Cundle 89mins), McDonald (Cornick 79mins), Parker. Subs not used: Nelson, Herd, List, Mbo.
Fleetwood: Cairns, McLaughlin, Bell, Eastham (Cole 70mins), Pond (Bolger 46mins), Ball, Grant, Glendon (Burns 70mins), Hunter, Dempsey, Davies. Subs not used: Urwin, Brannagan, Nirennold, Schwabl.
Attendance: 8,760 (172 away)