New Aberdeen boss Stephen Glass marked his first game in charge with a penalty shoot-out defeat of Livingston in the Scottish Cup.
Ross McCrorie netted the winning spot-kick to secure a 5-3 penalty victory after the sides had been locked at 2-2 after 120 minutes.
Aberdeen will face Dundee United at home in the next round.
The teams were tied after 120 minutes after the Dons twice battled back from behind.
Jay Emmanuel-Thomas twice fired Livingston into the lead with the Reds battling back via goals from Niall McGinn and Florian Kamberi.
However, Aberdeen suffered a major blow in the first half when captain and keeper Joe Lewis suffered an injury and had to be replaced by No.2 keeper Gary Woods.
Lewis was hurt in an accidental collision with Jon Guthrie and after treatment by the physios in the Dons’ penalty box was able to continue.
However, 15 minutes later the skipper was unable to play on and had to be replaced.
Dons boss Glass now faces a nervous sweat on the fitness of the influential keeper.
Within a minute of Lewis’ injury exit, the Dons were behind courtesy of a goal from Emmanuel-Thomas.
On-loan Oldham keeper Woods’ first touch of the game, on his Dons debut, was to pick the ball out of the back of the net.
Glass made two changes to the starting XI that defeated St Johnstone 1-0 in the Premiership last week.
The 44-year-old watched the action remotely from Perth from his hotel room whilst in 10-day quarantine due to Covid-19 overseas travel regulations having flown in from the United States.
One of Glass’ changes was enforced with left-back Jack MacKenzie cup tied having played in the tournament earlier in the season whilst on loan at Forfar Athletic.
Connor McLennan came in for MacKenzie.
Dropping to the bench was on-loan St Gallen striker Florian Kamberi, who had yet to score since being secured on transfer deadline day on January 31.
Replacing Kamberi was on-loan Stade de Reims striker Fraser Hornby, who had also yet to score since arriving on transfer deadline day.
Livingston created the first clear opportunity in the ninth minute when Emmanuel-Thomas played a pass to Nicky Devlin, who hit a powerful drive just over the bar from the edge of the penalty area.
Aberdeen should have broken the deadlock in the 16th minute when Niall McGinn dispossessed Jason Holt and broke upfield.
He played a pass to the onrushing Jonny Hayes, who drilled a low cross along the face of goal that found Connor McLennan 12 yards out.
McLennan sliced a right-footed shot well wide. He should have scored.
The Dons suffered an injury sweat in the 18th minute when Lewis crumpled to the ground following an accidental collision with Guthrie.
Lewis appeared to suffer a knock to his ribs and required treatment on the pitch by the Dons physios.
No. 2 keeper Woods was told to warm up, but Lewis was able to continue.
There was little fluid, attacking football on show from the Dons, but that was as much down to Livingston, who never gave them time in possession and disrupted any attempt at building momentum.
The Dons threatened in the 31st minute when Hornby fired in a low left-footed shot from 15 yards only to be denied by a solid diving save from keeper Max Stryjek.
Aberdeen were starting to threaten more, particularly down the left flank and from playing more balls in behind the defensive line.
Despite battling on bravely, Lewis was unable to continue and was replaced by No.2 Woods.
Losing both your captain and keeper, who had played every minute of the season so far, was a huge blow for Glass in his first game in the Dons’ dugout.
It got worse as Woods’ first touch was picking the ball out of the back of the net within a minute of his Dons debut.
Livingston went ahead when EMMANUEL-THOMAS kept the ball in on the far side after Hayes had ducked to let it go out for a throw in.
He then played a neat one-two with Scott Pittman.
Pittman returned the ball with a pass via the outside of his right foot to Emmanuel-Thomas, who showed great composure to move beyond Tommie Hoban before firing beyond Woods.
It was a great goal.
It was also a baptism of fire for keeper Woods, on loan from Oldham Athletic.
Half-time: Aberdeen 0 Livingston 1
In the 50th minute Dean Campbell swung in a free-kick into the box that met Lewis Ferguson, but his header was straight at keeper Sryjek who held.
Manager Glass made a change near the hour mark with a straight switch of Kamberi for Hornby, who was becoming increasingly isolated up front.
Kamberi was played down the left with McLennan moved inside through the middle.
Keeper Woods produced a vital block at the near post to deny a powerful 10-yard low drive from Devlin.
Aberdeen levelled in the 77th minute when Kamberi played a pass down the left to Hayes, who fired in a cross to find McGINN.
The Northern Ireland international composed himself and drilled a superb shot from 15 yards beyond Stryjek into the top corner.
Moments later Matty Kennedy was played in on goal by McGinn, but fired a vicious drive into the side netting.
That goal made an immediate, and significant difference and suddenly the Dons clicked in attack and looked far more potent.
However, they could not find that goal to win it in 90 minutes, as deep into injury time Matty Kennedy fired a 22-yard shot wide.
Full-time: Aberdeen 1 Livingston 1
Livingston regained the lead in the 93rd minute via the penalty spot.
A through ball from Devlin found Emmanuel-Thomas with his back to goal and was not in a position to get off a shot.
He went down under minimal body contact from Dean Campbell.
It was a soft penalty, but EMMANUEL-THOMAS stepped up and confidently stroked it into the top corner beyond Woods.
The Reds bounced back immediately in the 96th minute when McGinn played a pass across and substitute KAMBERI slid in to direct it into the net for his first Aberdeen goal.
It was the first time Aberdeen had scored two goals in a game since a 2-0 defeat of Motherwell on January 23.
In the 104th minute, Emmanuel-Thomas shrugged off a challenge from McCrorie and burst in on goal before unleashing a low 15-yard drive that flashed inches wide.
Extra time: Aberdeen 2 Livingston 2
In the 107th minute, substitute Hendry received a pass inside from Kennedy then shot low on the turn from 22 yards, but the effort flashed just wide.
- GOAL – Aberdeen 1 Livingston 0: Lewis Ferguson low into near corner
- GOAL – Aberdeen 1 Livingston 1: Alan Lithgow rifles into the roof of the net
- GOAL: Aberdeen 2 Livingston 1: Florian Kamberi nets with cool low finish.
- MISS: Aberdeen 2 Livingston 1: Jason Holt rattles the crossbar
- GOAL: Aberdeen 3 Livingston 1: Callum Hendry powerful drive past the keeper.
- GOAL: Aberdeen 3 Livingston 2: Jay Emmanuel-Thomas with a cool finish.
- GOAL: Aberdeen 4 Livingston 2: Dean Campbell sends the keeper the wrong way.
- GOAL: Aberdeen 4 Livingston 3: Aaron Taylor-Sinclair into near corner.
- GOAL: Aberdeen 5 Livingston 3: Ross McCrorie low drive.
ABERDEEN: Joe Lewis, Tommie Hoban, Andy Considine, Fraser Hornby, Niall McGinn, Jonny Hayes, Connor McLennan, Lewis Ferguson, Dean Campbell, Matty Kennedy, Ross McCrorie.
Subs: Gary Woods (for Lewis 36), Florian Kamberi (for Hornby 59), Callum Hendry (for McLennan 73), Ethan Ross (for McGinn 105).
Subs not used: Tom Ritchie, Callum Hendry, Dylan McGeouch, Michael Ruth, Calvin Ramsay, Ryan Duncan.
LIVINGSTON: Max Stryjek, Nicky Devlin, Jack Fitzwater, Jon Guthrie, Jackson Longridge, Jason Holt, Marvin Bartley, Craig Sibbald, Scott Pittman, Alan Forrest, Jay Emmanuel-Thomas.
Subs: Matej Poplatnik (for Forrest 80), Alan Lithgow (for Sibbald 90), Jack McMillan (for Longridge 106).
Subs not used: Robbie McCrorie, Aaron Taylor-Sinclair, Efe Ambrose. Josh Mullin, Jaze Kabia, Djibril Diani.
Referee: Colin Steven