St Johnstone secured a priceless three points in their pursuit of a top-six finish this season with this ultimately well-deserved victory over 10-man Inverness.
After a poor first half, Saints turned the screw in the second 45 but it looked like they would be left to rue a penalty miss by David Wotherspoon.
However, they bounced back late on to score what proved to be the winner by Chris Kane to end a run of three games without a victory and take them up to fifth in the Premiership table, level on points and goal difference with Ross County.
Home manager Tommy Wright tweaked his line-up from the side that lost last midweek at McDiarmid to Partick Thistle with midfielder Liam Craig dropping to the bench along with striker Graham Cummins with Simon Lappin and Kane who netted against the Jags coming in to replace them respectively.
Inverness boss John Hughes made one change from the team that drew with Hibs in the Scottish Cup quarter-final at the weekend with Liam Hughes replacing Miles Storey.
Inverness were quickly out of the traps and fashioned a great chance in just the second minute when Liam Polworth sent a deep cross in from their right towards Jordan Roberts but he could not keep his header down when he probably should have at least tested Alan Mannus in the Saints goal.
Nine minutes later, St Johnstone had a chance of their own when Steven MacLean delivered a superb cross-field pass into the feet of full-back Darnell Fisher who raced towards goal before sending a thumping 20-yard drive just over Owain Fon-Williams’ crossbar.
Caley were then presented with another opportunity when Tam Scobbie conceded a free-kick 22 yards from his own goal but Iain Vigurs sent his curling effort too high to trouble Mannus.
After that, both sides struggled to create much in an attacking sense with the game becoming bogged down in a war of attrition with far too many miss-placed passes snuffing out any chance of momentum.
There was finally another half-chance in the 40th minute when Fisher swung a cross in from the right but Kane’s header was a tame one and sailed harmlessly wide.
Saints then had a brief spell of pressure with Simon Lappin hitting a curling free-kick from the right that Fon-Williams had to punch clear, before Joe Shaughnessy rose highest to get his head onto a Danny Swanson corner but his powerful effort was too straight and was easily gathered by the Inverness keeper.
As the teams ran down the tunnel at half-time, neither manager would have been too happy with what he had witnessed from his side after what had been a poor 45 minutes of football.
The second half was just two minutes old when Wotherspoon tried his luck from long range but again it was another effort that sailed harmlessly over the bar.
The same player then had two chances but his first shot was blocked for a corner and his next, a crisp rising drive, was deflected behind again.
Saints though were at last starting to exert some sustained pressure with Inverness increasingly being pinned back.
And St Johnstone were presented with a gilt-edged opportunity to finally break the deadlock in the 68th minute. Swanson was chopped down as he broke into the Caley penalty area by Inverness skipper Gary Warren.
Referee Don Robertson had no hesitation in pointing to the spot before flashing a yellow card at Warren who had already been booked before producing a red to send the defender off.
Wotherspoon was handed the responsibility of taking the penalty but Fon-Williams dived to his right to pull off a crucial save to keep the scores level.
Saints looked to capitalise against the 10 men with Joe Shaughnessy next to come close but his shot hit the side netting, then Wotherspoon sent a long-range effort flashing just wide.
As the clock ticked down, it looked increasingly likely that the game would end goal-less but St Johnstone ensured that would not be the case in the 84th minute.
Fisher sent a cross in from the right which made its way through to Kane who stabbed home at the back post as he did the week before against Partick to send the home fans wild.
Attendance 2,157.
St Johnstone Mannus, Scobbie, Lappin, Anderson, Davidson, MacLean (Cummins, 83), Wotherspoon, Shaughnessy, Swanson (Craig, 87), Fisher, Kane.
Subs not used Clark, Doyle, Sutton, Thomson, Krachunov.
Inverness Fon-Williams, Tremarco, Warren, Draper, Roberts (Wedderburn, 73), Devine, Tansey, Hughes, Williams, Polworth (Horner, 87), Vigurs.
Subs not used Esson, Williams, Foran, Brown, MacLennan.
Referee Don Robertson.