McGregor struck in the 74th minute after Adam Rooney netted his second goal of the game to put Inverness back in front following a counter-attack.
Rooney had struck first early on but St Mirren turned the game around inside 77 seconds when Michael Higdon netted a penalty and Steven Thomson struck from long range.
Aaron Doran quickly levelled in the 33rd minute though before Saints edged the second half without getting their rewards.
Both teams remain without a Clydesdale Bank Premier League victory in 2011 but the draw consolidated Caley Thistle's place in the top six and moved St Mirren five points clear of bottom club Hamilton.
Inverness named five substitutes out of the seven allowed amid a host of injuries to the likes of Graeme Shinnie and suspensions to Grant Munro and Ross Tokely, but they created two chances within the first two minutes with Jonny Hayes hooking a shot straight at Paul Gallacher after 13 seconds.
Doran's low cross then found Richie Foran in a yard of space on the penalty spot, but the forward scuffed a left-footed shot straight at the goalkeeper.
However, Foran helped set up a sixth-minute opener when he flicked on Ryan Esson's long free-kick. Rooney turned McGregor and hooked the ball past the onrushing Gallacher from 10 yards.
It took Saints 24 minutes to stretch their opponents when right-sided midfielder David van Zanten released the breaking Thomson but Esson got down well to palm away the midfielder's angled shot.
The visitors had a let-off when the rebound bounced just too high for Higdon and Hugh Murray, making his first start for three months in place of the suspended Jim Goodwin, stabbed the ball against the outside of the post from eight yards.
Caley Thistle's luck soon ran out as Hayes, who has been struggling with an ankle problem, went off for Eric Odhiambo moments before they conceded a penalty.
The ball broke kindly for Craig Dargo after a challenge from David Proctor and the former Inverness striker went down over the left-back's outstretched leg with referee Bobby Madden pointing to the spot.
Higdon sent Esson the wrong way and St Mirren were ahead 77 seconds later. Dargo held the ball up and laid it off for Thomson to fire a first-time strike into the top corner from 20 yards to give Saints a 29th-minute lead.
But Inverness soon levelled when the St Mirren defence missed a cross from Proctor, now playing at right-back, and Doran ran across Marc McAusland to prod the ball past Gallacher from close range.
Saints immediately tried to hit back and Paul McGowan and Higdon both came close from long range while Dargo looked dangerous whenever he was allowed to turn and run at the away defence. McGowan was then booked for diving after a penalty-box challenge from Odhiambo.
The goalmouth action continued immediately after the break when Foran volleyed a deep cross from Lee Cox not far wide and Inverness soon had a double escape.
Jure Travner, on for Lee Mair at half-time, swung a corner to the back post for McGregor to head against the crossbar and Foran dived to head against the outside of the post as he cleared the rebound.
Left-back Travner was breaking forward to good effect as Saints dominated possession and Chris Hogg did well to head clear his inswinging free-kick after Doran had been booked for a foul on Van Zanten.
But the hosts were hit by a sucker-punch in the 61st minute. Another dangerous Travner cross was cleared and the visitors quickly got the ball up to Foran, who turned McGregor inside the centre circle and threaded the ball through for Rooney.
The striker outpaced John Potter and fired a left-footed shot across Gallacher and into the bottom corner from 16 yards.
The hosts continued to probe with the skilful and persistent McGowan at the heart of their approach play and they were rewarded in the 74th minute when McGregor rose to head Travner's outswinging corner into the roof of the net from 10 yards.
The defender almost repeated the feat from the same source with four minutes left but Esson parried the ball over from point-blank range.