Dean Lewington’s last-minute winner saw MK Dons claim a dramatic victory as struggling Gillingham slipped to within two points of the League One relegation places.
In a breathtaking final few moments that produced two goals, two red cards and a missed penalty, the home side emerged victorious to leave Gills down in 20th spot after suffering a fourth successive loss.
The visitors, who had trailed 2-0 after 10 minutes, had looked to have snatched a valuable point when Josh Wright slotted home a 90th-minute equaliser after seeing his initial penalty saved.
Dons defender George Williams received his marching orders for giving away that spot-kick, but the 10 men of MK Dons rallied and went down the other end to snatch a winner as captain Lewington netted his first goal of the season.
There was still time after that for Gillingham to also see a man sent off, with Bradley Dack dismissed after picking up a second yellow card, as the home side managed to hold on.
It took the hosts just five minutes to grab an opener as Robbie Muirhead unleashed a stunning strike into the top corner.
And it was 2-0 little more than five minutes later as Leicester loanee Harvey Barnes slotted home from inside the box.
But Gillingham responded and clawed one back 10 minutes after the break as Cody McDonald netted from Lee Martin’s cross, before Dons’ Williams saw red for bringing the scorer down inside the box a minute from time.
Wright missed the spot-kick but scored the rebound to equalise and make it 2-2.
However, there was still another twist in the tale as Lewington converted Ben Reeves’ cross in the final seconds before Dack was sent off for a second caution.
With Port Vale having won 2-0 at home to AFC Wimbledon, The Gills dropped to 20th place in League One, just two points above Shrewsbury Town in the final relegation zone, but crucially they have a game in hand.
Only five games are left for Ady Penoock’s side this season and having lost their last four, they entertain play-off chasing Millwall next weekend.
MK Dons line up: Nicholls, Williams, Walsh, Lewington, Baldock, Upson (Potter 69), O’Keefe, Reeves (Downing 93), Barnes, Muirhead, Agard (Bowditch 69).
Subs not used: Burns, Ngombo, Brittain, Maynard.
Goals: Muirhead (5), Barnes (10), Lewington (90+1).
Booked: Williams (69), Baldock (85), Bowditch (90+5).
Sent Off: Williams (89).
Gillingham line up: Holy, Jackson (List 78), Ehmer, Oshilaja, McDonald, Martin, Dack, Rehman, Byrne, Cornick (Parker 77), Wright.
Subs not used: Nelson, Hessenthaler, Donnelly, Quigley, Muldoon.
Goals: McDonald (56), Wright (90).
Booked: Ehmer (37), Dack (79), Oshilaja (86).
Sent off: Dack (90+3).
Referee: Carl Boyeson
Attendance: 8,807