Carey, whose set-piece deliveries were a threat throughout, sent an impressive free-kick sailing from outside the box high into the net to put the hosts in front two minutes from the interval.
However, Hearts responded immediately on the restart, Zaliukas bulleting home a header after Suso Santana had done well to work himself into position for a cross from the left.
Both sides had chances to snatch a late winner, with each goalkeeper making a crucial save in injury time.
Carey hit a 25-yard free-kick after being clattered as the first half reached its midway point but Jamie MacDonald beat it away for a corner and from the set piece, Hugh Murray hit a drive narrowly wide of the left-hand post.
David Obua then met Andrew Driver’s 25th-minute corner from the left with a powerful downward header, but the ball rolled to safety past the upright.
The same Hearts player came close again just before the half-hour – Gary Glen went on a good run from the halfway line and passed out to Driver on the left, and his deep cross to the towering striker was met by a header which was touched over the crossbar.
Carey was brought down by Jason Thomson just outside the box 10 minutes from the break and, taking the free-kick himself, sent in a superb shot which MacDonald had to soar up to his right to turn away.
His set-piece skills were rewarded two minutes from the break, as Carey put his side in front by sending a well-executed shot high into the net after Michael Higdon was brought down by Zaliukas.
Hearts were back on level terms just one minute into the second half after breaking upfield and winning a corner, fired in from the left by Driver.
It was cleared only as far as Santana on the opposite wing, and he turned neatly to create space to send in a cross which was bulleted home from close range by Zaliukas.
St Mirren mounted some pacy attacks as the game flowed from end to end and as the hour mark approached. Higdon impressively worked his way inside from a run up the right wing and found Billy Mehmet, but Andy Dorman’s eventual shot was deflected over in a busy penalty box.
Gallacher had to parry a raking shot from Obua, arriving at pace from outside the area.
Chris Innes headed over from a Carey free-kick and Carey was then dispossessed in his own box by Santana but home captain John Potter hurled himself in the way of the Hearts midfielder’s cross.
Hearts had to engage in some last-ditch clearing headers as both teams sought a late winner, while Craig Thomson tried his luck with a long-range drive 10 minutes from time which Gallacher had to palm out for a corner.
In the four minutes of injury time, home substitute Rory Loy went on a blistering counter-attack, passing three defenders and finding Higdon, whose on-target effort was turned round the post by MacDonald; and then Gallacher similarly turned a Calum Elliot drive over the bar.