Dundee threw away a 2-0 lead as Motherwell scored three times in the final 14 minutes to complete a remarkable Dens Park turnaround.
Georgie Gent, Theo Bair and Moses Ebiye shocked the Dark Blues into a late collapse to bring the Steelmen back into the shake-up for the top six.
That was after Jordan McGhee and Luke McCowan goals had the home side in a winning position – and had they held on, a top-half finish would have been assured.
The match turned on a VAR decision on 78 minutes that led to the Gent goal for 2-1 after Bair had seen his spot-kick saved.
Referee David Dickinson was also in the spotlight before the game after calling the pitch playable following two inspections – a decision Motherwell were unhappy with.
But it’s the Dee who finished the match the most disappointed as the Steelmen moved to within three points of them in sixth.
First half
Dundee were missing Trevor Carson, Ryan Howley, Curtis Main, Diego Pineda, Josh Mulligan and Owen Beck and named two goalkeepers on the bench alongside youngster Euan Mutale.
But McGhee was back in the starting XI after injury, taking the place of Owen Dodgson as Dara Costelloe moved across to left wing-back.
Despite the pitch conditions, the ball was moving fairly smoothly. Players on both sides, though, were taking few chances.
Early on Dan Casey fluffed a clearance before Blair Spittal missed a clearance from a corner that almost resulted in a Dundee goal.
But the Dark Blues enjoyed the better of the opening half.
Adam Devine did head wide for the Steelmen on 26 minutes before Antonio Portales went close to the opener on the half-hour.
He turned an Aaron Donnelly header into the side-netting. Lyall Cameron then saw a good effort blocked before Dundee took the lead on 36 minutes.
Cameron has enjoyed a fine run of late and it was his cross from the right that made the difference. He found Amadou Bakayoko at the far post to head back across goal.
And there was McGhee to nod into the empty net for his fourth goal in 11 matches.
By the time the half-time whistle went the wind began to pick up, making life even trickier for the players.
Second half
News came through early in the second period that St Johnstone had taken the lead at Easter Road. As things stood, Dundee were guaranteed to be in the top six with two matches to spare.
Motherwell, though, were much brighter after the break as Blair Spittal and Jack Vale went close.
Up the other end it was almost 2-0 as Mo Sylla burst from midfield and fed McCowan. His low effort, though, flew just wide.
McCowan did indeed make it 2-0 with 20 minutes left on the clock. Whether he meant it or not, only he knows.
His corner from the right was missed by goalkeeper Liam Kelly among a clutch of bodies and dropped inside the far post.
The lead, though, very quickly evaporated amid a haze of confusion.
VAR instructed ref Dickinson to go to the monitor to check a handball against Joe Shaughnessy in the Dundee area despite few appeals from the visitors. Penalty given.
Up stepped Bair but Jon McCracken pulled off a fine save only for Gent to knock in the rebound.
And moments later it was 2-2 as Bair ran through on goal and rolled the ball home with confidence on 81 minutes.
Less than five minutes beforehand, Dundee had been in front but suddenly were hanging on as Bair missed two gilt-edged chances to put the Steelmen in front.
But, into stoppage time, the Steelmen did complete the most unlikely comeback as sub Ebiye struck in the 94th minute to break Dundee hearts.
Tony Docherty’s side do remain in the driving seat for sixth spot with two games to go, leading Hibs by one point and ‘Well by three.
Player Ratings
Dundee FC:Â McCracken 6, Portales 6, Shaughnessy 5, Donnelly 5, McGhee 7, Costelloe 5, Sylla 7, McCowan 7, Cameron 7 (Robinson 90+4), Tiffoney 7 (Mellon 68), Bakayoko 7.
Subs not used:Â Legzdins, Sharp, Dodgson, Astley, Robertson, Boateng, Mutale.
Motherwell: Kelly, Gent, Spittal, Halliday (Ebiye 74), Bair, Casey, McGinn, Zdravkovski (Miller 74), Blaney, Devine, Vale (Butcher 90+4).
Subs not used: Oxborough, O’Donnell, Mugabi, Shaw, Nicholson, Ross.
Referee: David Dickinson
Attendance: 5,924
Conversation