Dundee were almost shocked by nine-man Inverness Caledonian Thistle in a frantic end to their 1-1 draw in the Highlands.
Two straight red cards for Scott Allardice and Brad McKay had the Dark Blues firmly in the driving seat in the closing stages.
After controversially having a Jason Cummings goal ruled out, Caley Thistle remarkably took the lead despite being two men less.
Daniel Mackay nipped in behind to open the scoring on 84 minutes and it looked like a night to forget for James McPake and his side.
However, Lee Ashcroft rose highest to level things with four minutes left with tempers flaring in the Highland capital.
Once more Charlie Adam was on the bench for Dundee and he was joined this week by striker Jason Cummings.
No goals in three outings saw James McPake switch things up front by giving Jonathan Afolabi a first start since November.
Also in was Christie Elliott for the injured Jordan Marshall while Cammy Kerr switched to left-back. Paul McGowan missed out but is expected fit for the weekend.
Neil McCann made one change from the cup defeat at St Mirren as Shane Sutherland replaced Miles Storey.
Former Dee Scott Allan started in the middle of the park.
Back at the venue where he made his first impact as a box-to-box midfielder, Jordan McGhee had the first effort of note.
Off balance, he couldn’t control the effort that dropped wide inside a crowded penalty area.
Adam Legzdins had to be on his toes on 10 minutes as Inverness had their first effort in anger.
Daniel Mackay nipped in behind as he blocked Lee Ashcroft’s clearance and earned a sight of goal from a tight angle only for Legzdins to tip wide.
The home side were looking dangerous in the opening stages with Allan integral to their attacking play.
Dundee hadn’t really got hold of the ball but they threatened once more through a Liam Fontaine long throw.
This one fell to the feet of Danny Mullen 12 yards out but his effort was deflected wide of target.
Inverness continued to test the visiting defence and would have been in front but for Legzdins on 23 minutes.
Nikolay Todorov beat the offside trap to run in behind before cutting it back for Sutherland but the goalkeeper was quickly out to block.
On 34 minutes, Mullen found some space and tried his luck from range but fired well into the stand from 25 yards.
The contest was even heading towards half-time as Todorov headed wide from an Allan corner.
The break saw a change from Dundee as Adam replaced Afolabi in a bid to get more control in the middle of the park.
Immediately the Dark Blues were a different proposition with Adam in determined mood.
However, it was Caley who created the big chance in the early stages of the half.
Allan showed his passing ability with a sublime throughball for Robbie Deas to run in behind.
Once more Legzdins was out quickly, making another big save to keep things level.
On the hour mark, it was the turn of Mark Ridgers at the other end to make a big stop.
A mix-up in defence gave Mullen a clear sight of goal 10 yards out but he couldn’t beat the goalkeeper and the scores stayed level.
And minutes later, Inverness were reduced to 10 men.
Midfielder Scott Allardice, already on a yellow, went in with two feet on Adam in the middle of the park.
Referee Mike Roncone showed no hesitation in showing a straight red card for the former Dundee United man.
Moments later, however, Caley were gifted an indirect free-kick inside the Dundee area after the referee adjudged Legzdins to have caught a backpass.
Todorov, though, couldn’t find a route through the packed wall.
Cummings was called for and almost made an immediate impact, latching onto a loose ball and forcing a save from Ridgers.
Time was running out to find a winning, though, and another corner went begging on 73 minutes – this time Fontaine heading wide under pressure.
With 12 minutes left Caley Thistle were reduced to nine men after Brad Mckay lunged in on Max Anderson.
And immediately Dundee took advantage. Or thought they had anyway.
Adam floated in the free-kick, it was flicked on and Cummings was there at the far post to head in.
But their joy was short-lived as the flag belated went up for offside to Dundee’s dismay.
Then came what looked to be a remarkable sting in the tail with six minutes left.
Mackay nipped in behind, breaking the offside trap and rolled the ball past the stricken Legzdins.
It looked liked an embarrassing night to forget for the visitors only for Ashcroft to rescue things with four minutes left.
He rose highest in the area to meet an Adam corner, grabbing his sixth goal of the season in the process.
Tempers were flaring between the dugouts but there was still time for a winner.
With the extra men, Dundee were pushing but Caley were holding firm.
The ball almost dropped for Cummings in the six-yard box only for a home leg to get in and clear.
In the end, time ran out for the visitors to earn a first-ever league win away to Caley Thistle and in the process secure a play-off place.
The point keeps the Dark Blues four points ahead of Inverness with two matches remaining.
ICT: Ridgers, Carson, McKay, Devine, Deas, Welsh, Allardice, Allan (MacGregor 69), D Mackay, Sutherland (Storey 69), Todorov (Harper 83).
Subs not used: C Mackay, McHattie, Vincent, Lyall.
Dundee: Legzdins, Christie, Ashcroft, Fontaine, Kerr, Byrne (Anderson 76), McGhee, McDaid, McMullan, Mullen (Cummings 64), Afolabi (Adam 46).
Subs not used: Ferrie, Jakubiak, Sow, Fisher.
Referee: Mike Roncone.