Hamilton Accies moved off the bottom of the Scottish Championship after their second win over Inverness in three days delivered a massive three points for their survival bid.
Dan O'Reilly's fourth goal of the season gave Accies the lead after 19 minutes before Scott Allardice grabbed an equaliser for Inverness just before half-time.
But Hearts loanee Connor Smith scored from the penalty spot to notch his third goal in as many games - and put Accies two points clear of rivals Arbroath at the foot of the table.
Inverness ended the game with 10 men following Billy McKay picking up two bookings in the final four minutes.
John Rankin's men have now won four of their last five league games and have lost just once in their last nine in all competitions.
It's a form surge at just the right time, as their victory came in their game in hand over Arbroath and with the sides due to meet at New Douglas Park on Friday, March 3.
Accies suffered a huge blow ahead of kick-off when Saturday's hero Lucas de Bolle missed out through injury. The Newcastle United loanee's absence was one of two changes from the 3-0 win in the Highlands.
Lewis Smith dropped to the bench and in came Andy Winter along with Steve Lawson, who was starting his first match since his return from injury last week.
It was the hosts who had the first sight of goal inside four minutes when John-Pierre Tiehi stole possession inside the Inverness half. He fed Connor Smith and when the Hearts loanee nudged the ball out wide to Reghan Tumilty, the midfielder's driven strike was well held by Jags keeper Mark Ridgers.
In the seventh minute Accies came agonisingly close to an opener when a neat through ball from Tiehi picked out Lawson. He got enough of a connection to poke the ball past Ridgers, but Cameron Harper saved the day for Inverness, sliding in to make a goal-line clearance.
The visitors had a huge chance of their own moments later when they surged up the pitch and Sean Welsh's header clipped the top of the crossbar from Nathan Shaw's delivery into the danger area. A curling effort from Scott Allardice in their next attack then flew narrowly wide in a pulsating start to proceedings.
The Jags were kicking themselves after 15 minutes when a bit of pinball in the penalty box saw the ball fall to Harper, but he dragged his shot wide from 15-yards from a great position.
And four minutes later Accies made them pay. Lawson played a short corner to Connor Smith and when he delivered a cross right on top of the Inverness defence, O'Reilly rose highest to power a downward header into the bottom corner.
Inverness pushed for an immediate response and the hosts breathed a sigh of relief when Shaw took aim from 20-yards and dragged his effort narrowly wide of Ryan Fulton's far post.
Rankin's men were far from comfortable and their visitors kept knocking at the door. Allardice clipped a cross to the back post in the 38th minute and Welsh strained every sinew as he glanced a header wide from just a couple of yards out.
Accies looked like they would get to the break unscathed but two minutes before the half-time whistle, Inverness got their equaliser. Hamilton couldn't clear their lines from a wide delivery and when the ball fell kindly to Allardice on the edge of the box, he kept his composure to arrow a low drive past Fulton.
Accies created the first opening of the second period when Tumilty's cross picked out Tiehi at the front post. The Frenchman should have taken it first time, but he tried to control the cross on his chest in the six yard box and the chance was gone.
Down the other end, Tiehi was on defensive duty moments later when he had to clear a Welsh header off the line.
Rankin soon turned to his bench and just seven minutes into the half he made a double switch, with Andy Winter and Fergus Owens making way for Chrissy McGinn and Newcastle loanee Dylan Stephenson.
Inverness really should have edged in front in 55 minutes when Jay Henderson's corner to the back post picked out defender Wallace Duffy unmarked. Thankfully for Accies, he lacked the clincial finishing of a striker as he somehow nodded wide from close range.
It was a huge let off and Accies had another in the 67th minute when O'Reilly misjudged a ball over the top. Billy Mckay pounced to drive forward and cross for Daniel Mackay, who poked the ball towards the target and past Fulton - only to see his effort come back off the post.
In 70 minutes Accies were screaming for a penalty for a handball when Harper looked to have blocked an effort from Tiehi in the box, but referee Colin Steven wasn't interested.
Three minutes later Steven did point to the spot when Connor Smith slipped in Stephenson and the striker was tripped in the box by Daniel Mackay as he went to shoot. Mackay was perhaps fortunate to pick up just a yellow.
It was Smith who stepped up and he fired a low effort past Ridgers to earn Accies the points.
The hosts had their hearts in their mouths when Billy McKay went down in teh box, but he was booked for simulation, earning a huge cheer.
It got worse for McKay as he picked up a second yellow in stoppage time to complete his and Inverness' misery.
They now welcome league leaders Queen's Park on Saturday.
HAMILTON: Fulton, O'Reilly, McGowan, Owens (McGinn 52), Tumilty, Martin, C Smith, Winter (Stephenson 52), Shiels, Lawson (L Smith 72), Tiehi.
Scorers: O'Reilly 19, Smith 73 (pen)
Bookings: Martin
Subs not used: J Smith, Easton, Zanatta, Newbury, Latona.
INVERNESS: Ridgers, Duffy, Harper, Devine, Carson (Deas 76), Shaw, Welsh, Allardice, Henderson, D Mackay (Samuels 76), Mckay.
Scorers: Allardice 43
Bookings: McKay, Allardice
Sent Off: McKay
Subs not used: C Mackay, Doran, Hyde, Delaney, Thompson, Boyd, Cairns.
Ref: Colin Steven
HT: 1-1
Att: 752
Follow Lanarkshire Live Sport on Twitter via @LanLiveSport, like us on Facebook or find us on Instagram for the latest sports news, pictures and video.