Kilmarnock recorded a dramatic first win of the season to move off the bottom of the Scottish Premiership and above Dundee United.
The result eases the pressure on the visitors' manager Gary Locke, but heaps more on United boss Jackie McNamara.
A Kallum Higginbotham penalty had put Killie in front but Billy McKay equalised with a spot-kick of his own.
But debutant Kevin McHattie fired a tremendous long-range winner to stun the home support.
United had bombarded the Kilmarnock goal in the second half, only to find Jamie MacDonald in inspirational form.
The goalkeeper produced outstanding saves to keep out McKay and Ryan Dow as they pressed for the winner.
He was mobbed by his team-mates at full-time as they acknowledged the role he played in the victory.
It was clinched, though, by an unlikely hero in McHattie, the full-back rifling in a low shot past Luis Zwick.
United will feel hard done by, having dragged themselves back into the match, but their profligacy in front of goal was their undoing.
They found themselves behind initially when Rory McKenzie nipped in in front of United captain Sean Dillon, who reacted slowly, catching the Kilmarnock winger and prompting referee Brian Colvin to point to the spot.
Higginbotham sent Zwick the wrong way with an expertly-taken penalty, high into the United net to give his side a half-time advantage.
If there were few arguments about that award, the equaliser came in more controversial circumstances.
Blair Spittal fired a volley goalwards, Lee Ashcroft threw himself in the way of the shot, with the ball coming off his arm.
Despite his protestations, Ashcroft's handball was deemed deliberate by referee Brian Colvin and McKay slotted the penalty down the middle to level the scoring – his first goal for United.
As United swarmed forward, there seemed likely to be only one winner, but that did not allow for the performance of MacDonald and the late cameo from McHattie.