A promising start from St Mirren saw Jason Naismith draw an early save from County goalkeeper Antonio Reguero before Yoann Arquin had an ambitious effort which sailed over the crossbar.
And the away side capitalised on their early pressure by taking a 16th minute lead. Mallan beat the defender before unleashing a shot which was parried into the path of Sean Kelly who made no mistake to slot the ball home.
Kenny McLean had a chance after running at the defence but pulled his shot wide before the midfielder rattled the crossbar with a left-footed effort minutes later.
St Mirren looked in complete control until a dangerous 38th minute challenge from Arquin on Lewis Toshney saw the County old-boy earn a straight red card from referee Brian Colvin.
County almost made St Mirren pay straightaway with Graham Carey forcing a save from Mark Ridgers before Jackson Irvine headed over the bar just before the interval.
The home side looked dangerous after the restart forcing Ridgers to make two saves from Carey either side of denying Craig Curran’s low drive across goal.
Darren Maatsen had a shot from the right-hand side of the box which drifted over before Carey was unable to find the target with his effort direct from a free-kick.
Martin Woods was the next man to test Ridgers as County’s efforts to get back on level terms against the 10 men looked to be in vain.
But eight minutes from time County got the equaliser they deserved when Irvine crossed for Liam Boyce to head into the bottom-right corner of the net.
Irvine had a chance to win it with a header that was saved by Ridgers moments later, but there was still another twist three minutes from time.
McLean managed to fashion a cross into the County box and Mallan was on hand to head a dramatic late winner from point-blank range.
Despite a couple of late corners County were unable to find another equaliser and slipped to their 14th defeat of the season – a result which sees them replace St Mirren at the bottom of the table.