Dundee United squeezed past Dunfermline into the last eight of the Scottish League Cup thanks to a couple of extra-time goals.
The strikes from first Scott Fraser on 96 minutes then sub Blair Spittal two minutes later ensured that the final scoreline flattered the home team.
Indeed, for long spells in this third-round match at Tannadice it was the Pars who looked the better team and had they taken their chances the pressure would have been piling up on United boss Jackie McNamara.
As it turned out, the anxiety that had been evident in regulation time finally disappeared.
The tie had finished 1-1 after 90 minutes.
Michael Paton opened the scoring for Dunfermline on 10 minutes and it was a goal to forget for home keeper Luis Zwick, who let the ball wriggle through his hands.
Callum Morris pulled the Tangerines level on 35 minutes with a header from close range.
It was then on to extra-time and Fraser was the hero for the Tangerines, picking the ball up midway inside the opposition half, striding forward then scoring with a low shot from 18 yards.
Spittal then got in on the act as he cut in from the right before finding the corner of the net with a left-foot curler.
The Tangerines had handed a surprise debut to 17-year-old left-back Jamie Robson, who earned his dramatic promotion due to Paul Dixon being injured and Sean Dillon suspended.
The good news for Pars fans was that their left-back Jason Talbot, who had been doubtful, made it.
The League One side, backed by a large travelling support, threatened through a Faissal El Bakhtaoui strike with just a couple of minutes gone.
The visitors then took the lead on 10 minutes.
It was a shocker for Zwick, who should have easily saved the 25-yard strike from Paton.
Looking well positioned and standing waiting on the ball arriving, the young German allowed the ball to slither through his fingers and drop into the net.
It wasn’t a surprise that the top scorers in the United Kingdom found the target. It was also a dream come true for Paton, who grabbed his first goal for the club.
Nevertheless, it was brutal blunder by Zwick.
United, stunned by that setback, won a freekick just outside the box on 15 minutes but it was blasted well over by John Rankin.
The Tangerines came close to an equaliser when a Charlie Telfer shot was deflected for a corner.
That very setpiece would lead to their leveller on 35 minutes.
It was taken by Fraser from the right and when Billy Mckay nodded the ball back across goal Morris was there to punish his old side with a powerful header.
The Pars almost restored their lead when a Ryan Wallace shot struck the post.
The visitors should have scored just before half-time but Wallace wasted a golden chance when he rounded Zwick, looked certain to score but clipped his shot across the face of goal. The angle was tight but it still should have been 2-1.
Mckay had a flurry of chances for the home side as they looked all the better for their break but the Pars’ defence stood strong.
Paton fired in a shot at the other end on the hour mark and the Pars then had another brilliant opportunity when Wallace raced from inside his own half and looked like pulling the trigger until challenged by Robson.
Rankin robbed Josh Falkingham of the ball in midfield on 70 minutes and fed it forward to Mckay, who played in sub Spittal. The youngster, who had replaced Telfer, slid his shot beyond the far post.
United, with Simon Murray and Adam Taggart on for Aaaron Kuhl and Darko Bodul, should have taken the lead on 75 minutes when Mckay was sent clear by Fraser.
However, the former Inverness man’s shot was saved by keeper Sean Murdoch at point-blank range.
It was then Murray’s turn to miss for United when he blasted the ball over after a great move involving Spittal and Fraser.
Up at the other end, El Bakhtaoui raced goalwards in yet another Pars’ break on 82 minutes but he was stopped by Zwick, who dived at his feet and the loose ball was sent wide by sub Michael Moffat.
With the game into stoppage-time, United should have wrapped up the victory but somehow Mckay’s superb cross was missed right in front of goal by both Taggart and Murray.
The extra-time saw United finally edge clear of their visitors, with Fraser and then Spittal wrapping things up in 96 and 98 minutes respectively.
Dundee United: Zwick, Robson, Morris, Mckay, Rankin, McGowan, Durnan, Telfer (60), Fraser, Kuhl (Taggart 73), Bodul (Murray 73). Subs not used: McCallum, Souttar, Dow, Connolly.
Dunfermline: Murdoch, Geggan, Talbot (McCabe 81) , Martin, Everton, Falkingham, Paton, Byrne (Hopkirk 91), Wallace (Moffat 68), El Bakhtaoui, Cardle. Subs not used: Hutton, Potter, Thomas, Antoine-Curier.
Referee: John Beaton.