Ragged ten-man Hearts limped into the Scottish FA Cup semi-final draw with a hard-earned win they scarcely deserved.
Partick Thistle, from two divisions below, looked the better side as they chased and harried the Jambos and ultimately were well worth a replay.
Hearts were coasting along at 2-0, but two quick yellow cards for substitute Roman Bednar gave Thistle a glimmer of hope.
And they nearly took advantage when Mark Roberts grabbed a goal 15 minutes from time to set up a grandstand finish.
However, despite plenty of pressure, the Jags could not find the second goal they needed to stay in the competition.
Hearts got off to a dream start when Paul Hartley's cross from the left was glanced home by Edgaras Jankauskas after only six minutes.
But the home side were poor and head coach Graham Rix had them out early warming up for the second half.
Despite this shock treatment, it took a breathtaking save from Craig Gordon to keep out Billy Gibson's deflected 25-yarder.
But it looked all over for Thistle when Deividas Cesnauskis scored a breathtaking solo goal after 64 minutes.
He cut in off the right wing and bent a perfect left-foot shot into the top corner.
Then Bednar got a second yellow for diving and Partick capitalised when Roberts bent a low shot past Gordon from 20 yards.
However, it was Roberts who missed the chance of the glory leveller as he blazed Adam Strachan's cutback over the bar to hand Hearts a semi-final spot.