The teams' second game in as many weeks looked set to end goalless until the Portuguese striker headed home a priceless decider for the home side to give them only their second league victory of 2010.
Accies striker Mickael Antoine-Curier had a goal chalked off after just 21 seconds as the hosts dominated the first half, but the second was more even and St Mirren twice came close through Graham Carey before the dramatic late ending.
The hosts' blistering start continued after the disallowed strike when Mark McLaughlin saw his header from Brian Easton's corner touched onto the left-hand post just one minute later.
A Dougie Imrie cross from the right then skimmed Paul Gallacher's crossbar with Antoine-Curier lurking and ready to turn it in at the far post.
Simon Mensing and David Barron were booked for an altercation as tempers frayed in the aftermath of a free-kick being fired into the Hamilton box. Antoine-Curier then tried a speculative effort from outside the box which he chipped wide of Gallacher's right-hand post.
The game became scrappier as the interval approached, with several bookings being issued by referee Euan Norris but no chances being created.
Antoine-Curier hit the post from a corner played into a packed box, and it looked as though the hosts would pay for their misses as St Mirren immediately mounted a pacy counter-attack.
Andy Dorman, in glorious isolation, sent in a shot which was cleared only as far as Craig Dargo on the right, but his effort looped towards the crossbar and was caught by Hamilton goalkeeper Tomas Cerny.
Hamilton had the first half-chance of the second half when Paixao and James McArthur set up Mensing for an acute-angled shot which was cleared, but Easton's corner was poor.
St Mirren won a free-kick on 52 minutes for McLaughlin's grapple with Billy Mehmet as the ball was lofted into the box. Carey's precise strike from the set-piece looked highly promising but hit the underside of the crossbar and rebounded to safety.
The match was far more even in the second half and the visitors came close when Mehmet's diagonal strike from the right whizzed narrowly wide on 57 minutes, and then again moments later when Carey's corner from the same side skimmed straight through the box.
Paixao played a neat one-two with Imrie to square across goal for Antoine-Curier, but the striker failed to connect with the inviting ball and Jack Ross swept it to safety.
Imrie later tried a snapshot as the game entered its final quarter but it was easily held by Gallacher.
The St Mirren goalkeeper beat away a close-range Paixao effort at the right-hand post a minute later.
Gallacher made a double block at the post from recently-introduced Marco Paixao as the game appeared set to peter out among a series of substitutions.
Lee Mair's hopeful late header went well over Cerny's crossbar and Carey launched a long-range shot which was turned onto the roof of the net as the 90 minutes drew to a close.
However, the action was not over - Easton sent in a cross midway through the three minutes of injury time which was flicked on by James Wesolowski to Flavio Paixao, and he scored with an assured header which went in beyond Gallacher's right hand.