Substitute Iain Wilson scored a stunning late solo goal to secure 10-man Kilmarnock a win over Dundee.
The teams were level at half-time after Sofien Moussa’s penalty cancelled out Eamonn Brophy’s opener for Killie.
The home side’s Gary Dicker was sent off for two yellow cards before debutant Steven Caulker headed Dundee in front.
Kris Boyd equalised, though, after excellent build-up play by substitute Lee Erwin.
Dundee assistant manager Graham Gartland was sent to the stands in the aftermath of Wilson’s goal, after complaining about the move that led to the winner.
Kilmarnock’s win was their seventh consecutive victory at Rugby Park – the first time they have achieved that since 1979 – and moved them level on points and goal difference with sixth-placed Motherwell.
Anyone who predicted how this match would unfold was wrong. It was utterly fabulous, and got better and better. A 90 minutes you simply didn’t want to end.
Caulker came in for his first Dundee start and by the end he must have wondered what on earth had just happened. He impressed, but ultimately was on the losing side.
Dundee started brightly going forward, but conceded a cheap early goal that made their task all the harder. From a corner, Boyd got a touch allowing the ball to drift away from goal towards front-line partner Brophy.
The striker did not hesitate, firing across Dundee goalkeeper Elliott Parish to find the far corner from a tight angle. It was a confident strike from a player who is not shy of having an effort on goal.
The presumption was that the home side would build on the breakthrough, but it did not materialise as Dundee took control.
Moussa was close with a header that crept over the bar, then Mark O’Hara shot straight at Kilmarnock goalkeeper Jamie MacDonald after good work by Simon Murray.
The signs were encouraging for the visitors. Dundee manager Neil McCann was about to change to a back four but stopped, presumably as he liked what he was seeing.
Jon Aurtenetxe fired a crisp left-foot shot that was well saved by MacDonald. Aurtenetxe’s next contribution was a flashing ball across goal that narrowly evaded Moussa.
Dundee’s equaliser duly arrived when Caulker powered a header goalwards with the ball apparently handled before being cleared. Dicker was booked, which later proved costly for the midfielder. Moussa calmly rolled the penalty home for what was a deserved leveller at that stage.
Kilmarnock manager Steve Clarke changed his side’s shape to a back three at the interval, but they quickly conceded from a corner.
The delivery from Roarie Deacon was fabulous, as was Caulkers’s dominance as he powered his header into the top corner. A wonderful goal in what was an impressive introduction to Scottish football for the English defender.
Referee Nick Walsh was unpopular with both sides, the result of some debatable calls. Those seemed to add to the occasion in a strange sort of way.
He failed to award Kilmarnock a free kick which clearly infuriated Dicker. The red mist descended followed by a red card, after he received his second yellow for cleaning Deacon out.
It turned into a classic encounter, a corker of a contest. Rory McKenzie shot straight at Parish, then Dundee responded when fabulous play from a Paul McGowan released Murray, but he fired narrowly over.
Kilmarnock changed to a 4-3-2 and were rewarded for that positivity. Erwin produced a moment of brilliance, then released Boyd whose first-time curling shot found the corner. It was a truly wonderful goal.
Both sides gave everything to win the game, but Kilmarnock found the answer, as they so often do under Clarke. The hero was to be 19-year-old Wilson.
He ran 40 yards, evading a number of challenges, dragged the ball from out of his feet then clipped it into the corner.
It was incredible and had home fans of all ages dancing wildly in the stands.
The drama continued when Gartland was sent to the stand, only adding to their glee. Yet there was still time for Caulker to threaten an equaliser late on, but his header was just wide.