A dramatic stoppage-time equaliser from Neil Yadolahi all but secured Bohemians’ Premier Division survival as they came from behind at Dalymount Park to draw 1-1 with Dundalk.
Dundalk had led from the 18th minute through Dane Massey, while skipper Stephen O'Donnell then missed a crucial late penalty before Bohs struck in the dying minutes.
Bohemians are now eight points clear of bottom sides Bray Wanderers and Shelbourne with two games to play. Bohs will be safe if Bray do not beat Limerick on Sunday.
The result also means that St Patrick’s Athletic will be crowned champions with victory over Sligo Rovers at Richmond Park on Sunday evening.
Trailing to Massey’s early lead and having created precious little throughout, Bohs left it very late to grab the vital point.
Dundalk keeper Peter Cherrie produced his only telling save of the night to turn Kevin Devaney’s stinging drive round a post in the second minute of added time.
Fellow substitute Darragh Reynor swung over the corner and central defender Yadohali powered home his first goal for the club with a towering header.
Despite four changes due to Darren Meenan and Chris Shields both being suspended, Richie Towell out injured and top-scorer Patrick Hoban only making the bench, Dundalk took the lead against the run of play on 18 minutes.
John Sullivan, playing in a central midfield role, dinked a superb ball over the top for the run of left-back Massey whose looping header dropped in over Dean Delany.
Bohs were almost level from an unlikely source within four minutes as Karl Moore’s free kick was headed narrowly wide of his own goal by Dundalk midfielder John Mountney.
Despite Bohs' possession, Dundalk might have had a penalty on 37 minutes. But referee Paul Tuite waved away appeals after Vinny Faherty looked to have been hauled down by Ryan McEvoy.
Faherty was then guilty of a bad miss when firing wide minutes later after Mountney broke on the right to set him up.
A sublime diagonal ball from Faherty then put Mountney through in the final minute of the half. Delany was out well to make a smart save with his feet.
The turning point in the game then came in the 78th minute when Dundalk missed a penalty.
O’Donnell failed to double his side’s lead when dinking his spot kick over the bar after its contentious award for a challenge by Luke Byrne on Mountney.
Four minutes later Delany raced off his line once again to save with his feet from Mountney before Yadolahi’s late equaliser.
Bohemians: Dean Delany; Derek Pender, Roberto Lopes, Neil Yadolhai, Luke Byrne; Keith Buckley (Andy Mulligan 60), Dave Mulcahy (Darragh Reynor 60), Ryan McEvoy, Karl Moore; Stephen Traynor (Kevin Devaney 79); Dinny Corcoran.
Dundalk: Peter Cherrie; Mark Rossiter, Brian Gartland, Andy Boyle, Dane Massey; John Mountney, John Sullivan, Stephen O’Donnell, John Dillon (Francis McCaffrey 60); Kurtis Byrne (Nathan Murphy 85); Vinny Faherty (Pat Hoban 88).
Referee: Paul Tuite (Dublin).