The Buddies came from behind to win at the Caledonian Stadium after Lee Cox netted from close range in the eighth minute.
Thomson's 25-yard screamer levelled matters seconds before half-time and he hit the winner with five minutes remaining.
Danny Lennon made three changes to his St Mirren starting line-up for the trip north as goalkeeper Paul Gallacher returned for the first time since the sides last met in September, when Caley Thistle won 2-1.
The stopper, who replaced Craig Samson, had missed out since then after undergoing surgery to repair some damaged cartilage in his knee.
Other changes for the Buddies saw former Inverness forward Craig Dargo return after being out since August with a knee injury and David Barron was also included, with David van Zanten moving to the bench and Gareth Wardlaw suspended.
The hosts made one change with young striker Shane Sutherland replacing influential midfielder Jonny Hayes who was sidelined by an ankle injury.
Inverness started brightly and took an early lead through Cox.
The midfielder benefited from a lucky bounce after Richie Foran's lofted shot from the edge of the box rebounded off the crossbar into his path for a simple close-range finish.
St Mirren almost levelled on the 20-minute mark when Dargo forced an acrobatic diving save from Inverness goalkeeper Ryan Esson when his thunderbolt from 20 yards almost found the top corner.
Esson produced two more super saves as the Buddies hunted the equaliser.
He thwarted Buddies top scorer Michael Higdon, whose volley from the edge of the box followed a poor headed clearance from Stuart Duff and Dargo squandered the rebound.
Moments later Esson was called into action once more with a fingertip save after Paul McGowan's low shot was deflected.
But Esson was helpless to stop Thomson's stunning 25-yard screamer moments before the interval. Picked out by Dargo, the midfielder shot beyond the diving Esson in the 44th minute.
St Mirren started the second half where they left off with Higdon firing just over as they searched for a second goal.
McGowan and Jure Travner combined well before McGowan forced another save from Esson, with the Paisley club in the ascendancy.
Inverness might have snatched the lead again in the 65th minute had top scorer Adam Rooney managed to connect with a low Foran cross.
Foran's ball across the face of the six-yard box was just too fast for Rooney as he slid in at the far post.
Rooney was then blocked by fellow Irishman Patrick Cregg after Sutherland's cross-cum-shot hit the woodwork in the 71st minute.
Moments later Russell Duncan blasted over when the ball was laid back to him by Rooney.
Esson's diving save in the closing stages stopped Marc McAusland's angled drive but he failed to keep the Buddies at bay for long.
Thomson's late strike shocked the hosts as he connected with a cross from substitute Sean Lynch to fire home from 12 yards with only five minutes remaining.