Imagine breaking Hearts on Valentine's night?

St Johnstone thought they had done just that. This William Hill Scottish Cup fifth-round replay was meandering towards extra time when Murray Davidson popped up in the 83rd minute to prod home and put St Johnstone on course for a quarter-final clash of the all Saints with St Mirren.

Yet Hearts are made of sterner stuff. This was a match they desperately wanted to win for both football and financial reasons and they pulled it off with a remarkable turnaround. The catastrophe engulfing Rangers may have put the Tynecastle club's own crippling financial woes in the shade but these remain torrid times.

Before last night's duel, the Edinburgh club's directors revealed they had settled an outstanding tax bill while they made assurances the players would be paid their wages on time tomorrow.

A decent cup run, and the cash that it generates, would all help in bridging the gap between the club's financial commitments and liabilities. Jamie Hamill kept those hopes alive when he levelled matters with a controversial penalty in injury time before Marius Zaliukas, the captain, thrashed in the winner with three minutes of extra time left after a furious goalmouth scramble.

It was a sore one for last year's semi-finalists, and Steve Lomas, the manager, expressed his disappointment at the penalty decision which turned the match.

"It was a very, very, soft penalty," he said. "I'm not going to criticise the referee, I'll get into trouble for that. He [Suso] chops the ball inside and he sees Maybury and just falls into him. You've got to be 100% certain that it's a penalty and I can't see it with that one. We've got it won at that point and it's a massive call from the ref."

Having been left bruised and battered by Saturday's 5-1 mauling by Dundee United, Lomas administered some rapid surgery on his side in an effort to soothe the wounds.

Peter Enckelman was given the heave ho after his goalkeeping blunders and replaced by debutant Alan Mannus while Alan Maybury, Frazer Wright and Davidson were also brought in as part of the facelift.

After seeing their side leak three goals in a calamitous closing seven minutes of Saturday's trouncing, the Saints supporters must have taken encouragement from the sprightly start made by the hosts as they set about making amends for that reversal.

A couple of early corners signalled their intent as Hearts swiftly found themselves embroiled in some defensive chores.

Despite these initial, menacing advances, it took until the 22nd minute for a genuine opportunity to arrive. Liam Craig knocked a pass across the face of the area but Jody Morris, with a clear sight of goal, screwed his effort wide. Moments later, a telling thrust, engineered by the industrious Francisco Sandaza, sent Cillian Sheridan striding in but his deflected strike was parried to safety by Jamie MacDonald, the visiting goalkeeper.

Hearts had struggled to gain any real foothold in the game but, having been saved by their goalkeeper, they immediately burst up field and tested newcomer Mannus. Rudi Skacel's searing strike packed a fearsome punch but the former Shamrock Rovers custodian stood firm and repelled the danger. The second period was largely uneventful but just as thoughts began drifting towards extra time, St Johnstone scored with seven minutes remaining.

Lee Croft cut in from the right and fed Davidson, who poked the ball high into the net. That appeared to be that but Hearts, who plundered a point against Kilmarnock in stoppage time at the weekend, staged another dramatic late show as they rallied in the last knockings. Suso Santana was brought down in the box by Maybury and Hamill calmly stroked home the penalty. Buoyed by that let off, Hearts entered extra-time with renewed vigour and they were rewarded as the clock ticked down. An almighty rammy in the area, which saw the ball rattle the cross bar, ended with Zaliukas providing the decisive strike.

"From where I was, I can't make an opinion on the penalty," said Hearts manager, Paulo Sergio. "I'm just very proud of my players."

After a fraught night, it was Hearts who came up smelling of roses.