Inverness Caledonian Thistle moved off the bottom of the Scottish Premier League after claiming three valuable points against St Mirren in Paisley.
Andrew Shinnie benefited from a blunder in the home defence to fire in an 11th-minute opener.
A first-half injury-time header from Steven Thompson levelled the scores at the break before a superb Jonny Hayes second-half strike claimed the points.
Thompson's late header almost sneaked a draw, keeper Ryan Esson saving well.
The win edges Terry Butcher's side up to ninth, two points above Aberdeen who now prop up the table. St Mirren slip to seventh.
Thompson returned to the starting line-up for the hosts, with full-back David van Zanten dropping out following last week's 5-0 defeat at Celtic Park.
Inverness made just two changes following their defeat by Hearts - one was enforced with Roman Golobart replacing the injured Josh Meekings, while Billy McKay was preferred to Gregory Tade up front.
With just under 10 minutes played, Thompson had a shot from close range that cleared the bar when he really should have found the net.
One minute later, the Inverness account was opened when Hayes stole possession and squared to Shinnie on the edge of the St Mirren penalty area to blast home.
McKay had the ball in the back of the St Mirren net five minutes later, but referee Euan Norris had already blown for offside.
St Mirren struggled to keep the ball out of their own half for most of the opening half-hour, although Chris Hogg had to be on his toes to keep out a dangerous Jeroen Tesselaar cross.
As the interval approached, Ross Tokely should have done better with a long-range effort from outside the St Mirren penalty area that sailed wide, then teammate Greg Tansey's right-footed shot from 18 yards inched past the near-side post.
On the stroke of half-time, McKay hit the St Mirren side-netting after running out of steam on the goal-line and Kenny McLean's long-range shot could not find a way through a throng of Inverness jerseys.
However, seconds before the half-time whistle Thompson rose unchallenged at the back post to meet a Gary Teale corner and head into the net.
Shortly after the re-start, St Mirren keeper Craig Sampson had to dive low to his right hand side to stop a McKay header, then Kenny Gillet had to be on full alert to clear a Paul McGowan cross at the other end.
Inverness keeper Esson kept out a right-footed Thompson shot from 18 yards out, then Teale powered in a long-range free-kick from the right-hand side of the pitch with Esson at full-stretch to tip the ball over the bar.
Inverness regained the lead when Hayes curled in a superb shot on the turn from 20 yards out.
Moments later, McKay could have increased the advantage further when he ended up in a goalmouth scrap and swung a foot at the ball from a prone position, but his effort inched wide of the mark.
The home fans' claims for a penalty in the final minutes were waved away when Gillet appeared to handle the ball inside the Inverness penalty area.
Two minutes of added on time were not enough for the hosts to scrape an equaliser, despite a close-range header from Thompson that Esson managed to hold on the line to secure three precious points.
Sorry, we were unable to load match stats, please try again.
Live Text Commentary
Full Time The referee signals the end of the game.90:00 +2:32
Outswinging corner taken by Graham Carey, clearance made by Ross Tokely.90:00 +2:26
The ball is sent over by Graham Carey, Ross Tokely gets a block in.90:00 +1:41
Jon McShane takes a shot. Ryan Esson makes a save.90:00 +1:23
David Davis challenges Paul McGowan unfairly and gives away a free kick. Indirect free kick taken by Jim Goodwin.86:35
Corner taken by Kenny McLean from the right by-line played to the near post.86:30
The ball is crossed by Kenny McLean, Kenny Gillet gets a block in.86:11
David Barron produces a cross, Chris Hogg makes a clearance.84:30 Substitution
Substitution Gregory Tade comes on in place of Billy McKay.84:30 Substitution
Substitution Lee Cox joins the action as a substitute, replacing Richie Foran.83:14
Graham Carey crosses the ball, save made by Ryan Esson.82:30
Outswinging corner taken from the left by-line by Graham Carey.82:24
Centre by Graham Carey, blocked by Ross Tokely.81:50
The official flags Greg Tansey offside. Illias Haddad takes the indirect free kick.81:08
The referee blows for offside against Jon McShane. Ryan Esson takes the free kick.79:50
Free kick awarded for an unfair challenge on Johnny Hayes by Jeroen Tesselaar. Indirect free kick taken by David Davis.79:05 Booking
Booking The referee cautions Kenny Gillet for unsporting behaviour.77:25
David Barron has an effort at goal from just outside the area which goes wide of the left-hand post.76:52
Chris Hogg concedes a free kick for a foul on Steven Thompson. Jim Goodwin takes the indirect free kick.76:27
Jon McShane is caught offside. Ryan Esson takes the free kick.
The ball is swung over by Kenny Gillet.73:54 Substitution
Substitution Jon McShane is brought on as a substitute for Nigel Hasselbaink.73:54 Substitution
Substitution (St Mirren) makes a substitution, with Graham Carey coming on for Gary Teale.72:45
Johnny Hayes has a shot on goal from outside the area which misses right.71:54
The assistant referee flags for offside against Billy McKay. Gary Teale takes the indirect free kick.69:20
Effort on goal by Billy McKay from inside the box misses to the right of the target.68:17
The assist for the goal came from Greg Tansey.68:17 Goal scored
Goal! - Johnny Hayes - St Mirren 1 - 2 Inverness Johnny Hayes finds the net with a goal from just outside the penalty box to the bottom left corner of the goal. St Mirren 1-2 Inverness CT.64:44
Richie Foran is ruled offside. Indirect free kick taken by Craig Samson.62:29
Direct free kick taken by Chris Hogg.62:29 Booking
Booking David Davis is cautioned.62:21
Unfair challenge on David Davis by Steven Thompson results in a free kick.60:14
Foul by Steven Thompson on Ross Tokely, free kick awarded. Free kick taken by Chris Hogg.59:27
Johnny Hayes takes the outswinging corner, Headed effort from deep inside the penalty area by Ross Tokely goes harmlessly over the crossbar.57:46
The ball is crossed by Nigel Hasselbaink, Ross Tokely gets a block in.57:06
Steven Thompson crosses the ball.56:18
Inswinging corner taken left-footed by Kenny McLean played to the near post, clearance made by Johnny Hayes.55:17
Ross Tokely concedes a free kick for a foul on Nigel Hasselbaink. Strike on goal comes in from Gary Teale from the free kick.53:13
The ball is crossed by Ross Tokely, save by Craig Samson.52:00
Johnny Hayes takes a shot.51:08
Jim Goodwin concedes a free kick for a foul on Andrew Shinnie. Greg Tansey takes the direct free kick.49:54
The ball is sent over by Paul McGowan.49:35
Steven Thompson takes a shot. Save by Ryan Esson.48:46
The ball is delivered by Paul McGowan, Kenny Gillet manages to make a clearance.47:51
Johnny Hayes takes a inswinging corner from the right by-line to the near post, Marc McAusland manages to make a clearance.46:59
A cross is delivered by Kenny Gillet, Billy McKay takes a shot. Save made by Craig Samson.45:01
The second half begins.45:01 Substitution
Substitution Lee Mair leaves the field to be replaced by David Barron.45:00 +3:07 Half time
Half Time The referee blows for half time.45:00 +1:50 Goal scored
Goal! - Steven Thompson - St Mirren 1 - 1 Inverness Steven Thompson finds the net with a headed goal from inside the six-yard box. St Mirren 1-1 Inverness CT.45:00 +1:28
Corner taken right-footed by Gary Teale from the left by-line,45:00 +1:00
Kenny McLean takes a shot. Blocked by Chris Hogg.45:00 +0:20
Johnny Hayes crosses the ball, save by Craig Samson.43:37
A cross is delivered by David Davis.41:57
Centre by Gary Teale, clearance by Chris Hogg.40:00
Kenny McLean decides to take a short corner.38:54
The ball is sent over by Jeroen Tesselaar.37:33
Corner taken right-footed by Greg Tansey, save made by Craig Samson.36:32
Greg Tansey produces a right-footed shot from just outside the box that goes wide left of the goal.35:53
Long range effort by Ross Tokely goes wide right of the target.35:08
The referee blows for offside against Nigel Hasselbaink. Ryan Esson takes the indirect free kick.33:58
The ball is delivered by Billy McKay, save by Craig Samson.29:58
Inswinging corner taken right-footed by Gary Teale from the left by-line, clearance by Chris Hogg.29:53
The ball is sent over by Jeroen Tesselaar, clearance by Chris Hogg.28:01
Kenny Gillet gives away a free kick for an unfair challenge on Paul McGowan. Free kick taken by Marc McAusland.26:19
Free kick awarded for a foul by Paul McGowan on Andrew Shinnie. Johnny Hayes takes the free kick.25:13
Foul by Richie Foran on Illias Haddad, free kick awarded. Jim Goodwin takes the free kick.24:15
Johnny Hayes takes a inswinging corner from the right by-line to the near post, Headed effort on goal by Greg Tansey from just inside the box goes harmlessly over the target.23:43
Greg Tansey takes a shot. Jim Goodwin makes a clearance.23:07
Free kick awarded for a foul by Illias Haddad on Andrew Shinnie. Johnny Hayes takes the indirect free kick.22:24
Free kick awarded for an unfair challenge on Roman Golobart by Steven Thompson. Roman Golobart takes the free kick.19:48
Corner taken left-footed by Johnny Hayes from the right by-line, Lee Mair makes a clearance.19:27
The ball is delivered by Kenny Gillet, Marc McAusland gets a block in. Blocked by Marc McAusland.17:19
Unfair challenge on David Davis by Nigel Hasselbaink results in a free kick. David Davis restarts play with the free kick.16:34
The referee blows for offside. Craig Samson restarts play with the free kick.14:12
Outswinging corner taken by Johnny Hayes from the left by-line.13:32
Inswinging corner taken right-footed by Johnny Hayes from the left by-line, Andrew Shinnie takes a shot. Blocked by Paul McGowan.11:59
Nigel Hasselbaink challenges Roman Golobart unfairly and gives away a free kick. Free kick taken by Ryan Esson.10:17
The assist for the goal came from Johnny Hayes.10:17 Goal scored
Goal! - Andrew Shinnie - St Mirren 0 - 1 Inverness A goal is scored by Andrew Shinnie from deep inside the penalty area to the bottom left corner of the goal. St Mirren 0-1 Inverness CT.7:21
Shot from inside the area by Steven Thompson clears the bar.6:52
Inswinging corner taken from the left by-line by Gary Teale.6:41
The ball is crossed by Nigel Hasselbaink, blocked by Ross Tokely.5:23
The official flags Steven Thompson offside. Ryan Esson takes the free kick.4:24
Effort on goal by Nigel Hasselbaink from deep inside the penalty area misses to the right of the target.3:05
Free kick awarded for a foul by Billy McKay on Jim Goodwin. Craig Samson takes the free kick.0:07
Free kick awarded for a foul by Lee Mair on Richie Foran. Johnny Hayes takes the direct free kick, Kenny McLean delivers the ball, Kenny McLean manages to make a clearance.0:00
The referee gets the game underway.
Live data and text provided by our data suppliers