St Johnstone won through to the semi-finals of the Betfred Cup with a 4-3 penalty shootout win over Dunfermline at East End Park.
After a goalless 90 minutes, Shaun Rooney drove Saints into the lead four minutes into extra-time before Pars substitute Iain Wilson levelled with a shot in the 113th minute and then came the tension of penalties.
Perth goalkeeper Zander Clark made saves from Paul Watson and Kevin O'Hara with Wilson and Kyle Turner scoring.
Craig Conway, Stevie May and Callum Booth all scored for the Premiership side with Callum Hendry hitting the woodwork which left Liam Craig with the opportunity to win the tie and he made no mistake.
Both sides went into the game on the back of rare league defeats.
Saints had lost their first game in 12 against Livingston in the Premiership at the weekend and were looking to make amends.
Likewise Championship Pars had lost their first game of the season at home to Morton on Saturday.
The visitors started the quarter-final tie better and in the 12th minute wing-back Scott Tanser fired a drive from 20 yards past the post before defender Rooney glanced a David Wotherspoon corner wide of the far post.
The home side came close in the 27th minute when Dom Thomas whipped in free-kick from wide which was gratefully turned round the post for a corner by St Johnstone goalkeeper Clark.
The Perth men survived consecutive corners before a Thomas cross zipped across the six-yard box with no takers.
Saints then passed up a great chance to score when a perfect Wotherspoon cross was somehow headed over the crossbar from six yards by midfielder Murray Davidson.
St Johnstone striker Chris Kane came close with a drive from 20 yards early in the second half as the visitors still looked the more likely.
Dunfermline goalkeeper Owain Fon Williams saved a decent Liam Gordon header from a Wotherspoon corner.
May took over from Kane on the hour mark with Dunfermline enjoying some good possession and a clever chip by Thomas just cleared the bar.
The game descended into attrition and endless series of crosses blocked and passes cut out before entering extra-time.
Saints' goal was quality. Tanser's deep cross was pulled out of the air by Rooney and from 16 yards he smashed the ball low into the far corner of the net to celebrate his first goal since joining from Inverness.
St Johnstone then piled forward for more.
May had a couple of efforts on goal then missed a sitter from six yards before Rooney came close to a second with a drive which was deflected past for a fruitless corner.
Dunfermline rallied when the teams turned around again and Wilson, on for Fraser Murray at half-time in extra-time, slammed in the leveller with his first goal for the Pars since joining from Kilmarnock in the summer.
Then came the penalties lottery with Saints coming out on top.