Grant Munro's early opener was cancelled out by Jim Hamilton but Caley Thistle showed their stomach for the fight when Ross Tokely claimed the decisive goal late on.
With bottom side Falkirk earning a surprise win over Motherwell, victory in this clash was crucial for both sides but it was Terry Butcher's men who were celebrating in the end.
Saints boss Gus MacPherson wrote in his programme notes that he predicted the last five games of the season would be "nervy, fascinating and at times unbearable" - and he was right about at least two of those today.
Both sides made changes for the clash in Paisley. Saints drafted John Potter, Hamilton and Garry Brady into their starting line-up following last week's Homecoming Scottish Cup defeat against Rangers.
They were also boosted by the news that Hugh Murray and Scott Cuthbert had been passed fit after both were rated doubtful with groin problems.
Butcher opted to swap goalkeepers, with Ryan Esson dropped to the bench in favour of Michael Fraser being given a rare outing for the Highlanders.
Fraser was called into action early on when Andy Dorman delivered a free-kick from the left deep into the box for Hamilton to nod on for Cuthbert, whose header was collected by the Caley Thistle goalkeeper.
Cuthbert then had a quick opportunity to make amends when he threw himself in front of a Dorman corner only to nod wide of the target.
At the other end, Richie Foran had the ball in the back of the net but only after bundling the ball out of Mark Howard's grasp and the header was disallowed for the foul on the Saints keeper.
With just 12 minutes gone, Inverness had the net bulging again and this time there were no complaints from referee Steve Conroy.
Ian Black delivered the corner into the box for Munro to send a stooping header over the line despite the best efforts of Jack Ross to clear the danger.
Saints could have restored parity when Dorman's corner found Hamilton at the back post and he nodded back across goal for Billy Mehmet.
But the striker could only hold his head in frustration as he nodded narrowly over the crossbar from 10 yards and squandered the opportunity to haul the home side level before the interval.
Inverness could have doubled their advantage after the restart with Dougie Imrie sending a swerving effort just high and wide of the target.
He then had another go moments later, this time dispatching a powerful effort from inside the box which dipped just over the crossbar.
With the Caley man causing all sorts of problems down the right, it was no real surprise to see Mo Camara replaced by David Barron.
Saints threw themselves a lifeline when Hamilton met Mehmet's cross before finishing from close range with 20 minutes to go - and seconds before being replaced by Sean Burns.
But it was the 312 Inverness fans who had made the long trip from the Highlands who were celebrating again when Tokely restored their lead after 83 minutes.
He initially tried to set up Adam Rooney but his effort was blocked by Howard. The ball broke to Tokely and this time the goalkeeper had no chance with the left-footed half-volley.
Black then came to the rescue to hook a Cuthbert effort off the line as Inverness held on to secure a massive victory in their fight for survival.