A 10-man St Johnstone side ended Ross County's unbeaten league run of 40 games with a win at Victoria Park.
Liam Craig opened on the half-hour for the visitors with a strike from 30 yards, but Rowan Vine was sent off one minute later for violent conduct.
Sammy Morrow latched onto a Grant Munro cross to equalise from close-range in the 67th minute.
Saints regained the advantage in the closing stages with Frazer Wright heading a corner home from six yards.
County had early chances but failed to capitalise, with Rocco Quinn and Gary Glen both testing visiting keeper Alan Manus.
Ross Tokely then came close with a header and fellow defender Scott Boyd closer still with another effort from a corner.
The home side continued to dominate but suddenly St Johnstone were a goal up against the run of play.
When the ball broke to Craig the midfielder lashed a fantastic long-range strike past Michael Fraser.
However, the Saints fans' delight turned to despair just over a minute later when Vine appeared to take a swing at Richard Brittain and the visitors had to make do with 10 men.
County pressed for the equaliser which might save their unbeaten run and into the second half Iain Vigurs came close from distance.
Then the Saints missed a golden chance when substitute Murray Davidson somehow slammed the underside of the bar from close range and the ball just failed to cross the line.
Gregory Tade was the next to miss in a better spell for the 10 men. But County quickly reasserted themselves and drew level when Munro set up Morrow to knock the ball home at the left post.
It was constant pressure from County and substitute Colin McMenamin forced a full length save from Mannus when he broke clear.
Morrow might then have put the home side ahead but his effort was headed off the line.
The County goal had a let off in the 85th minute when Saints' sub Steven MacLean forced Michael Fraser to turn the ball for a corner.
From the Craig's resulting corner, Wright rose above the County defence to head home the winner - and Saints almost went further ahead in injury-time when David McKay cracked a free kick of the inside of the post before it was cleared.