Hamilton 1 Dundee 2
AJ Leitch-Smith's goal seven minutes into stoppage time snatched a 2-1 win for Dundee at Hamilton.
Mark O'Hara's own goal had put the Dark Blues in trouble at the SuperSeal Stadium after just 90 seconds.
But with Accies a man light after seeing David Templeton sent off for two quick-fire bookings, 18-year-old Matthew Henvey's first ever senior goal put them level with 13 minutes left before Leitch-Smith popped up at the death to claim the points for Neil McCann's side
The result sees Dundee leapfrog Accies into ninth place in the Ladbrokes Premiership.
The hosts were without Greg Docherty following his move to Rangers but Georgios Sarris was back on the bench after boss Martin Canning reversed his decision to banish the Greek from the club.
Dundee had lost their four previous clashes with the Lanarkshire men and found themselves staring at a fifth inside two minutes.
Kevin Holt misjudged the flight of Danny Redmond's free-kick as he nodded it back into traffic. O'Hara then compounded that blunder as he sliced his clearance into his own net.
McCann would have been pleased to see his side respond encouragingly to that early setback.
But their failure to make more of their chances yet again sent the Dens boss into a dark mood as he grumbled away on the touchline.
The sight of Dark Blues frontman Faissal El Bakhtaoui getting in the way of team-mate Holt's goal-bound shot did not help.
The reception El Bakhtaoui got from the home support was just as frosty when he went down easily while trying to turn past Alex Gogic inside the box.
The 20 minute mark saw another opening as Gary Woods pushed Paul McGowan's shot back into the danger zone but Gogic cleared before Leitch-Smith could pounce.
Hamilton came within a lick of paint of adding a second 11 minutes into the second period as David Templeton lined up a free-kick. He clipped a delicate strike over the wall but found himself foiled as it hit the inside of Elliot Parish's post before bouncing out.
Sofien Moussa had the ball in the Accies net after 65 minutes but saw the goal chalked off after running offside to collect O'Hara's through ball.
But the visitors found themselves playing against 10 men for the final stages as Templeton got his marching orders after first catching Glen Kamara with a late lunge after 68 minutes before tripping Scott Allan five minutes later.
Dundee made the numerical advantage count with 13 minutes left as substitute Henvey levelled. Allan played a short corner to O'Hara before receiving it back and sweeping in for the on-rushing teenager, who calmly finished into the roof of the net.
As the clock ticked past 90 Hamilton were out on their feet. They then found themselves down to nine men as Darian MacKinnon limped off.
McCann's men sensed their chance and got it when Accies sub Marios Ogkmpoe tripped Allan out wide. A quick free-kick freed up Kamara who found Leitch-Smith to convert from close range.