St Johnstone extended their unbeaten away run to five games with victory over 10-man Kilmarnock.
But the match will be remembered for the controversial sending off of Kilmarnock captain Manuel Pascali.
Murray Davidson opened the scoring for the visitors, but Michael Nelson thought he had rescued a point with his second half header.
Rowan Vine's toe-poked finish with two minutes remaining saw the Perth side claim all three points.
Pascali was shown a straight red card by referee Stevie O'Reilly after six minutes for a robust challenge on Nigel Hasselbaink.
It looked as though Pascali took the ball cleanly, but the referee disagreed and brandished the red card.
Pascali's red card saw Kenny Shiels sent to the stand for his protest
Kenny Shiels was furious and a few minutes later was sent to the stand.
With their numerical advantage, St Johnstone enjoyed most of the early possession as Kilmarnock had to reshuffle their pack.
The visitors could have taken the lead with chances for Gregory Tade and Liam Craig - Cammy Bell standing firm in the Killie goal on both occasions.
But the pressure finally told after half an hour; Tade scuffed a shot on the edge of the box and Davidson swept home from 10 yards.
St Johnstone might have doubled their lead had they been awarded a penalty just five minutes later, but the referee instead booked Vine for diving when it looked as though he was illegally felled in the box.
Perhaps feeling an element of injustice during the half-time interval, Kilmarnock came out for the second period looking vibrant and striker Paul Heffernan came close for the hosts.
He ghosted past two St Johnstone defenders before unleashing a vicious shot from 20 yards that was palmed away by Alan Mannus.
Cillian Sheridan also came close to equalising, but his snap shot volley from a tight angle arched high and wide.
With an increasing freedom about their play, Kilmarnock left space for their opponents to exploit, and both Liam Craig and Chris Millar had chances to cement the three points.
From his adopted position in the stand which was in fact just behind the dugout, Kenny Shiels urged his side forward as the game entered its final stages.
And their endeavour was rewarded with 10 minutes remaining when Nelson rose to nod beyond Mannus.
At that stage it looked as though there would only be one winner as Killie pressed for an unlikely three points.
But given the cruel fate that football often conjures up, St Johnstone, against the run of play, stole a victory with two minutes remaining.
Millar played through Vine, and as Bell rushed from his goal, the substitute poked past the Kilmarnock goalkeeper.
Full Time The game is over, as the referee blows his whistle.
Mohamadou Sissoko fouled by Gary Miller, the ref awards a free kick.
Cameron Bell restarts play with the free kick.
90:00 +0:55 Booking
Booking Gary Miller is cautioned.
Assist by Chris Millar.
88:36 Goal scored
Goal! - Rowan Vine - Kilmarnock 1 - 2 St J'stone Rowan Vine finds the net with a goal from the edge of the penalty area to the bottom right corner of the goal. Kilmarnock 1-2 St Johnstone.
Substitution David Robertson replaces Liam Craig.
Corner from left by-line taken by James Dayton.
The assist for the goal came from James Dayton.
84:04 Goal scored
Goal! - Michael Nelson - Kilmarnock 1 - 1 St J'stone Michael Nelson finds the back of the net with a headed goal from close in. Kilmarnock 1-1 St Johnstone.
Foul by David MacKay on James Dayton, free kick awarded. James Dayton sends in a cross,
Substitution Gregory Tade goes off and Gary Miller comes on.
Substitution (Kilmarnock) makes a substitution, with James Dayton coming on for Jeroen Tesselaar.
Substitution Danny Racchi replaces Borja Perez.
Free kick awarded for an unfair challenge on Steven MacLean by Michael Nelson. Callum Davidson restarts play with the free kick.
Chris Millar is caught offside. Cameron Bell restarts play with the free kick.
Murray Davidson takes a shot. Save by Cameron Bell. Corner taken by Rowan Vine from the right by-line, Unfair challenge on Mohamadou Sissoko by Steven Anderson results in a free kick. Free kick taken by Cameron Bell.
Outswinging corner taken left-footed by Liam Craig from the left by-line, free kick awarded for a foul by Steven MacLean on Cameron Bell. Cameron Bell takes the free kick.
Foul by Gary Harkins on Rowan Vine, free kick awarded. Direct free kick taken by Steven Anderson.
Cillian Sheridan produces a right-footed shot from close range which goes wide of the right-hand post.
Borja Perez takes the free kick.
Booking Caution for Steven MacLean.
Foul by Steven MacLean on Paul Heffernan, free kick awarded.
Foul by Mohamadou Sissoko on Gregory Tade, free kick awarded. Steven MacLean produces a strike on goal direct from the free kick, Cameron Bell makes a save.
Free kick awarded for a foul by Michael Nelson on Frazer Wright. Alan Mannus takes the free kick.
Outswinging corner taken right-footed by Borja Perez from the right by-line, Frazer Wright makes a clearance.
The free kick is delivered right-footed by Borja Perez from left wing, Steven Anderson makes a clearance.
Booking David MacKay booked for unsporting behaviour.
David MacKay gives away a free kick for an unfair challenge on Gary Harkins.
Free kick awarded for a foul by Jeroen Tesselaar on Rowan Vine. Free kick taken by David MacKay.
Inswinging corner taken right-footed by Borja Perez, Liam Craig manages to make a clearance.
The offside flag is raised against Steven MacLean. Indirect free kick taken by Cameron Bell.
Corner taken by Borja Perez, Strike from close range by Mohamadou Sissoko clears the bar.
Steven MacLean has an effort at goal from close range which goes wide right of the target.
Free kick awarded for an unfair challenge on Cillian Sheridan by Steven Anderson. Direct free kick taken by Gary Harkins.
Shot by Liam Craig from deep inside the penalty area misses to the left of the goal.
Liam Craig has an effort at goal from outside the penalty box which goes wide right of the target.
Borja Perez takes a outswinging corner from the right by-line played to the near post.
Murray Davidson gives away a free kick for an unfair challenge on Gary Harkins. Gary Harkins restarts play with the free kick.
Borja Perez takes a shot. Save by Alan Mannus.
Steven MacLean challenges Borja Perez unfairly and gives away a free kick. Michael Nelson takes the free kick.
Unfair challenge on Steven MacLean by Gary Harkins results in a free kick. Callum Davidson takes the direct free kick.
The referee gets the second half underway.
45:00 +0:59 Half time
Half Time The referee calls an end to the first half.
Rowan Vine produces a right-footed shot from just outside the box that misses to the right of the goal.
Rowan Vine takes a short corner.
Effort from outside the penalty box by Cillian Sheridan goes wide left of the goal.
Substitution Mohamadou Sissoko joins the action as a substitute, replacing Lee Johnson.
Shot from just outside the box by Rowan Vine misses to the left of the target.
Headed effort from inside the area by Liam Craig misses to the right of the target.
Booking Rowan Vine booked for unsporting behaviour.
Murray Davidson takes a shot. Cameron Bell makes a save. Inswinging corner taken by Liam Craig, Murray Davidson challenges Cameron Bell unfairly and gives away a free kick. Cameron Bell takes the direct free kick.
Borja Perez concedes a free kick for a foul on Callum Davidson. Frazer Wright takes the direct free kick.
Assist by Gregory Tade.
30:57 Goal scored
Goal! - Murray Davidson - Kilmarnock 0 - 1 St J'stone Goal scored by Murray Davidson from close in low into the middle of the goal. Kilmarnock 0-1 St Johnstone.
Substitution (St Johnstone) makes a substitution, with Rowan Vine coming on for Nigel Hasselbaink.
The offside flag is raised against Callum Davidson. Cameron Bell restarts play with the free kick.
Shot by Liam Craig. Save made by Cameron Bell.
Liam Craig takes a shot. Save by Cameron Bell.
James Fowler delivers the ball, save by Alan Mannus.
Steven MacLean has an effort at goal from just outside the area which goes wide of the left-hand post.
Outswinging corner taken from the left by-line by Liam Craig, Borja Perez makes a clearance.
Foul by Gary Harkins on Murray Davidson, free kick awarded. Alan Mannus takes the free kick.
The free kick is delivered left-footed by Jeroen Tesselaar from left wing, Foul by Cillian Sheridan on Frazer Wright, free kick awarded. Direct free kick taken by Alan Mannus.
Booking Chris Millar is shown a yellow card for unsporting behaviour.
Foul by Chris Millar on Cillian Sheridan, free kick awarded.
Gregory Tade takes the chance to get an effort at goal. Save by Cameron Bell.
Handball by Liam Craig. James Fowler takes the free kick.
Steven MacLean takes a shot. Save by Cameron Bell.
Cillian Sheridan concedes a free kick for a foul on David MacKay. Direct free kick taken by Steven Anderson.
Jeroen Tesselaar fouled by Gregory Tade, the ref awards a free kick. Gary Harkins takes the free kick.
Cillian Sheridan takes a shot. Save made by Alan Mannus.
Jeroen Tesselaar challenges Steven MacLean unfairly and gives away a free kick. Free kick taken by Steven Anderson.
Gary Harkins fouled by Nigel Hasselbaink, the ref awards a free kick. Cameron Bell takes the direct free kick.
Dismissal The referee red cards Manuel Pascali for violent conduct.
Foul by Manuel Pascali on Nigel Hasselbaink, free kick awarded. Direct free kick taken by David MacKay.
Steven MacLean challenges Manuel Pascali unfairly and gives away a free kick. Michael Nelson takes the free kick.
This page is best viewed in an up-to-date web browser with style sheets (CSS) enabled. While you will be able to view the content of this page in your current browser, you will not be able to get the full visual experience. Please consider upgrading your browser software or enabling style sheets (CSS) if you are able to do so.