Firstly, the in-form winger teased his way through the middle of a powerless St Mirren defence before netting with a calm finish to put the visitors ahead on 63 minutes.
Then it was another Templeton run which prompted a late hack on him from John Potter which saw the St Mirren defender sent off with nine minutes remaining.
Kevin Kyle stepped up to put away the penalty and secure a victory which leaves Hearts in third place in the Clydesdale Bank Premier League and the only credible title challenger to Rangers and Celtic.
Hearts were without striker Stephen Elliott, meaning Calum Elliot was drafted into the attack, while Rudi Skacel was out with a calf problem.
Jamie MacDonald was in goal for Marian Kello as the visitors aimed to repeat their 3-0 win at Tynecastle in October.
St Mirren were without the suspended Gareth Wardlaw, leaving Paul McGowan to support Michael Higdon up front.
St Mirren were the first to threaten in the fourth minute, Higdon's flicked header setting up McGowan for a dipping volley that dropped just over the crossbar.
Hearts responded on 12 minutes when a cross from the left by Ruben Palazuelos was chested down by Kyle, but his fierce shot was deflected wide by Paddy Cregg.
The visitors had another opportunity when David Templeton was brought down by Steven Thomson on the edge of the area, but Ryan Stevenson wasted the resulting free-kick.
St Mirren made a 24th-minute enforced change when the injured McGowan, seemingly clutching his side, made way for Craig Dargo.
Templeton, who had switched to the right flank, found himself unmarked on 32 minutes and set up Ian Black for a shot from distance that bounced wide of the target.
MacDonald made his first save of the contest when another Higdon header put Thomson clear, but his angled drive was fired against the legs of the goalkeeper.
Hearts had the first chance after the restart when, after good work from Stevenson, the ball broke to Black who sent a first-time effort from the edge of the area just over the bar.
St Mirren full-back Jure Travner raced forward down the left but his cross, aimed at Higdon, was headed away expertly by Eggert Jonsson.
St Mirren were looking more dangerous now and threatened again when Darren McGregor's header landed kindly for Dargo, who diverted over from close range.
The deadlock was finally broken by a truly special goal on 63 minutes, Templeton weaving his way through the centre of the St Mirren defence before composing himself to slot beyond Paul Gallacher.
Hearts almost added a second when Stevenson was twice denied by Gallacher, the brilliant double save keeping the home side in contention.
Both teams made changes late on, David Obua on for Elliot for Hearts, while St Mirren withdrew Marc McAusland for Aaron Mooy to bolster their forward options.
Templeton was not finished yet, however, and on 81 minutes another storming run was brought to an end with a despairing lunge by John Potter, prompting an immediate red card.
Potter had no complaint as he trudged off, leaving Kyle to complete the punishment by slotting home the spot-kick.
Kyle almost added a third for Hearts when he headed over a Palazuelos cross, but the damage had been done.