Olly Lee was the Hearts hero as his late goal earned a 1-0 win over Dunfermline to send the Ladbrokes Premiership side into the Betfred Cup quarter-finals.
Dunfermline struck the post with an early shot from Faissal El Bakhtaoui and found Hearts keeper Zdenek Zlamal impossible to beat in a frantic cup tie.
In the end, it was Lee’s low strike 11 minutes from time that gave Hearts the victory.
Hearts were given plenty to worry about throughout as Dunfermline held their own against their top-flight visitors.
Hearts began with plenty of confidence after last weekend’s victory against Celtic but, after a brief flurry in the Pars box in the second minute, it was the home team who looked more threatening in attack.
And they came close to the breakthrough in the 11th minute.
Louis Longridge robbed Uche Ikpeazu inside the Hearts half and found James Craigen who sent El Bakhtaoui scampering clear on the right side of the box.
The striker had support but opted to shoot and watched on in despair as his effort crashed back off the post.
The huge Hearts following shouted for a penalty in the 16th minute when striker Ikpeazu hit the deck trying to reach a cross but referee Bobby Madden waved aside the appeals.
Myles Hippolyte was then inches away from a Jackson Longridge centre as he found a rare bit of space in the area.
But, without a goal that their endeavours sought, Dunfermline found themselves with defending to do as the half wore on.
Hearts finished on top and Lee’s drive took a nick off a home defender on its way over the bar before Mark Durnan was forced into a brave block when John Souttar shot from the edge of the box.
The teams continued to trade blows after the interval and again Dunfermline threatened.
El Bakhtaoui looped a header over before an acrobatic bicycle kick from Ryan Williamson’s deep cross was beaten away by Hearts keeper Zlamal.
Jake Mulraney swept a shot across goal in the 78th minute but Lee showed him how to do it a minute later.
The midfielder was allowed space inside the box and his drive went through the legs of Danny Devine to find the far corner of the net.
Even then, the Pars refused to bow to their visitors.
Zlamal tipped a Devine header over just as it appeared to have dipped over him.
And then in the fourth minute of injury-time Zlamal produced a stunning block to prevent a point-blank effort from Dunfermline substitute Aidan Connolly from crossing the line.
Stay updated with the latest news, gossip and football stories by following us @Football_P