Aberdeen made unconvincing progress in the Europa League after a 1-0 defeat by Fola Esch in Luxembourg.
Aberdeen were ultimately thankful for two injury-time goals at Pittodrie after Samir Hadji reduced their first qualifying-round aggregate lead to 3-2 when the hosts exposed a shaky Dons defence in the final minute of the first half.
The visitors survived a major scare when Fola hit the post and they edged through after a difficult finale with the injured Willo Flood struggling to make any contribution.
Aberdeen had an early warning at the Stade Josy Barthel when a ball over the top sent Hadji away, but Joe Lewis saved at his near post.
The Dons settled and Shay Logan and Kenny McLean both shot just wide from distance before the visitors got their first effort on target in the 20th minute. Peter Pawlett got round the outside of the Fola defence down the left and crossed low for Jayden Stockley, whose near-post effort was blocked by the goalkeeper.
Logan had a penalty appeal rejected before the hosts began to increase their attacking threat. They were off target from a Hadji header and Stefano Bensi volley but the Dons did not heed the warnings as a slackness crept into their defensive play.
And Fola threw the tie wide open when one simple pass cut the Dons open. Centre-back Andrew Considine pressed the ball as Bensi received an inside pass, but a first-time ball put his strike partner clear with Ash Taylor slow to respond.
The forward, whose father Mustapha helped Morocco knock Scotland out of the 1998 World Cup, raced into the box and fired high into the net.
Derek McInnes made two half-time changes with Mark Reynolds and Flood on for Anthony O'Connor and Pawlett, but his side were almost two down within five minutes when Taylor allowed Bensi to turn and sat off him 25 yards out. The striker curled the ball towards the top corner and Lewis pulled off an excellent diving stop.
The English goalkeeper saved from Tom Laterza following the resulting corner before the Dons appeared to take control of the game.
But the respite proved brief. Some sloppy possession play in the 75th minute saw Aberdeen stretched at the back and Emmanuel Francoise cracked a 22-yard drive against the inside of the post.
With Flood limping badly and the Dons having used three substitutes, Aberdeen were effectively a man down and Lewis saved from a curling effort from Gerson Rodrigues.
Aberdeen should have had a penalty with eight minutes left when substitute Adam Rooney was clearly tripped by Billy Bernard, but the Norwegian referee booked the incredulous Irishman for diving.
That set up a fraught finish but Lewis ultimately secured the Dons' progress when he scrambled to catch Hadji's hooked effort.
ends
Europa League News
Which Premier League clubs will qualify for the Champions League, Europa League and Europa Conference League?
The Premier League season is in the final stretch, and the race for a place in Europe next season is starting to hot up. Here's who can qualify.
Top Russian clubs appeal to CAS to return to UEFA competitions
The top four clubs in Russia's football league said they have filed an appeal to CAS against being banned from next season's European competitions.
Champions League, Europa League tifos: This season's best fan displays after Eintracht Frankfurt's pyrotechnics
This season's Champions League, Europa League and Conference League have all seen incredible displays of fan support. Here are some of the best.
Rangers seal Europa League finals spot with comeback against RB Leipzig
John Lundstram struck 10 minutes from time to give Rangers a 3-1 win over RB Leipzig and send them into the Europa League final 3-2 on aggregate.
Eintracht Frankfurt ease past 10-man West Ham into Europa League final
Eintracht Frankfurt beat West Ham 3-1 on aggregate in their Europa League semifinal to reach their first European final in 42 years.
Arrests made as Frankfurt, West Ham fans clash before Europa League semifinal
More than 30 arrests were made after supporters of West Ham and Eintracht Frankfurt clashed before their Europa League semifinal, police said.