A remarkable breakaway goal from Greg Stewart put the seal on a wonderful win for Dundee at Rugby Park.
The final seconds were ticking away as Kilmarnock chased an equaliser in what was a fantastic finale.
Home goalie Craig Samson was in the Dark Blues’ box for a corner but when the ball broke upfield Stewart took off.
Around about the halfway line, he jumped a challenge by Samson, chipped the ball on and then made it into the Killie box with the goal unguarded.
His shot looked sure to make it 3-1 but Jamie Hamill appeared from nowhere to hook it off the line.
Back the ball came to Stewart, though, and he made sure second time around to make it 3-1.
It was incredible stuff.
It was Stewart who had given the visitors the lead just a minute before the break, then his fellow frontman David Clarkson made it 2-0.
They appeared to be in control until 76 minutes when a lovely piece of skill by Alexei Eremenko saw him pull the ball out of the air at the back post then fire home with his left foot.
The greatest drama was still to come though.
Dundee keeper Scott Bain was a hero in the 89th minute when he saved superbly from a Rory McKenzie shot and then came the magical moment from Stewart that secured the three points.
Attendance: 4,481.
Dundee team: Bain, Irvine, Konrad, McPake, McGinn, McAlister, Harkins (Roberts 89), McGowan, Stewart, Clarkson (Thomson 83), Boyle. Subs not used: Schenk, Davidson, McBride, Kerr, Dyer.
Referee: Greg Aitken.