Rooney netted his 20th goal of the campaign from close range in the 85th minute – 15 minutes after Russell Duncan had been sent off following a bust-up with St Mirren captain Lee Mair.
The result gave Terry Butcher’s side revenge for their home loss to the Paisley side in December. Bottom side Hamilton beat Hibs 1-0 to move within three points of the Buddies.
Leading scorer Rooney was dropped as Caley Thistle made six changes to the side which beat title-chasing Celtic 3-2 midweek.
Club captain Richie Foran returned from suspension for Inverness, while Northern Ireland goalkeeper Jonny Tuffey made his SPL debut.
Midfielders Duncan, Gavin Morrison and Eric Odhiambo, as well as Burnley’s on-loan striker Alex MacDonald were included for Caley Thistle, as Lee Cox, Chris Innes, Nick Ross, Shane Sutherland and goalkeeper Ryan Esson were benched alongside Rooney.
St Mirren made three changes to the team which lost 1-0 to Hamilton last Monday with David Barron, Mark McAusland and Kenny McLean replacing benched David Van Zanten, injured Hugh Murray and suspended Jure Travner.
Chances were limited throughout the first half with a very quiet opening 10 minutes only punctuated by St Mirren’s Kenny McLean sending a 25-yard free-kick over the bar.
Michael Higdon fired wide for the visitors on 13 minutes when the ball evaded Inverness’s back line.
Moments later the hosts forced their first corner which landed with Morrison, who volleyed over the top of the away stand.
The first shot on target came from the hosts in the 26th minute when MacDonald was played through by on-loan Blackburn midfielder Aaron Doran.
The striker’s effort was blocked by St Mirren stopper Paul Gallacher in the one-on-one situation. The rebound landed with Foran, who was unable to capitalise.
Moments before the break Inverness full-back Kenny Gillet burst down the left wing before crossing to Odhiambo, who headed wide.
Rooney entered the fray eight minutes into the second half, replacing MacDonald.
Higdon’s header from a Steven Thomson cross was stopped by Tuffey in the 55th minute.
It sparked life into Inverness with Rooney producing an acrobatic overhead kick which struck the crossbar just before the hour.
Rooney had a further chance in the 64th minute when he headed a Doran free-kick wide.
Higdon sent a low 25-yard free kick around the post on 68 minutes as the visitors pressed forward.
Moments later Higdon played in Paul McGowan, who forced an expert save from Tuffey.
Inverness were ruffled and Duncan was sent off 20 minutes from time after a tussle with St Mirren captain Lee Mair.
Duncan, who will be released by Inverness at the end of the season, was distraught as he left the field to a standing ovation from the home fans.
He appeared to have been caught in a tangle with the Paisley defender while fans called for a penalty, but referee Bobby Madden showed him red for raising his hands after consulting linesman David Watt.
Four minutes later Rooney struck the junction of bar and post as Inverness responded to the setback.
Rooney completed his hat-trick of hitting the woodwork in 82 minutes when his angled strike hit the post after being put through by Nick Ross.
But the Irishman was not to be denied three minutes later when he netted his 20th goal of the season. Rooney was found by Doran before lifting the ball over the advancing Gallacher for the decisive goal.