Jordan McGhee's 89th-minute winner gave Dundee a dramatic but deserved Scottish Premiership comeback victory over St Johnstone in a superb Tayside derby at Dens Park.
St Johnstone scored against the run of play after nine minutes when Matty Smith curled in from the edge of the box.
Dundee's dominance was finally rewarded 15 minutes from time when Luke McCowan converted a controversial VAR penalty award after Liam Gordon was judged to have fouled Amadou Bakayoko.
Dundee pushed for the winner and it was McGhee who nodded in Owen Beck's cross to send the home crowd into raptures.
Tony Docherty's side remain sixth, but go three points clear of seventh-placed Hibernian, while St Johnstone stay 10th, five points above Ross County having played two games more.
Despite the differing narratives between these two sides this season, just two points separated them at kick-off.
From the outset though, Dundee set about terrorising the visiting defence through McCowan, Scott Tiffoney and Lyall Cameron, but they could not find a route to goal.
St Johnstone's opener after only eight minutes was a surprise to all apart from Smith, who teed himself up nicely before picking out the bottom corner from 20 yards.
Dundee reacted well. Bakayoko hit the post when he closed down goalkeeper Dimitar Mitov's clearance, while Joe Shaughnessy and Aaron Donnelly both had headers go close.
St Johnstone did have chances to double their lead. Benjamin Kimpioka and Adama Sidibeh were denied by fine Trevor Carson saves, but the visitors could not take advantage of their pace on the counter.
Dundee continued to press in the second half, swinging in cross after cross but lacking the final touch. They needed a helping hand and got one when Gordon dragged his hand across Bakayoko's face when a corner came in. The VAR, Don Robertson, spotted it and called David Munro to the screen.
Penalty given, and McCowan duly struck it in off the post to bring Dundee level.
The hosts, now with with wind in their sails, searched for a winner and found it quickly when McGhee powered a header past Mitov.
There was plenty of added time after Michael Mellon's serious-looking head injury, but Dundee were able to hold on for a vital win - just their third in 13 games.
Player of the match - Owen Beck
Dundee dominance finally pays off - analysis
When managers talk about turning performances into results, you usually take it with a pinch of salt. This time though, Tony Docherty was spot on.
When Dundee come forward, it's like watching young boys play. Bags of energy and tricks, desperate to beat a man and have a shot - they just need to find that clinical edge.
You wonder if they'd have been able to rescue anything had they not been gifted a penalty. It was just the confidence boost they needed.
As for St Johnstone, for a large part of this afternoon, they were up into the top six. Despite coming in for criticism from some quarters, Craig Levein and Andy Kirk have done a decent job.
The Perth team were clinical, scoring with their first chance, and threatened without creating a large amount. However, they'll be furious they threw this away.
Dundee host Ross County in the Premiership on Saturday (15:00 GMT) while St Johnstone welcome Rangers the next day (12:00).
Life-and-death decisions on the frontline: The Bafta award-winning Ambulance returns to Greater Manchester
How is Irish stout made? Gregg Wallace goes Inside the Factory to find out...