Jason McCartney's penalty six minutes into injury-time earned Ballinamallard a vital Premiership win over Coleraine.
The win further eases Ballinamallard's relegation worries as they are now nine points above bottom club Institute.
The Mallards took the lead on 27 minutes as Steve Feeney headed a John Currie corner to the net.
Matthew Snoddy levelled on 37 minutes and while Coleraine had David Ogilby sent off on 75, a draw looked certain until the last-gasp penalty drama.
Referee Raymond Hetherington awarded the spot-kick after adjudging that Coleraine's Stephen Douglas had handled a Cathal Beacom shot.
Coleraine players protested angrily but despite a long delay, McCartney held his nerve to slot his penalty past Michael Doherty.
Ogilby was dismissed in the 75 minute after getting two yellow cards in four minutes, with his tackle on Stuart Hutchinson ultimately leading to his early bath.
Coleraine had produced all the early pressure but then found themselves behind on 27 minutes as Feeney nodded Currie's cross past Doherty.
The Bannsiders levelled on 37 minutes as Snoddy fired home after a long throw from Aaron Canning.
Ballinamallard had a couple of escapes after the break as a couple of Joe McNeill crosses caused some consternation in the home defence.