Linfield are through to the Europa League second qualifying round after a 4-3 defeat by Faroes side NSI Runavik gave the Blues a 5-4 aggregate victory.
Reece Glendinning put Linfield ahead but Klaemint Olsen and Pol Justinussen goals put the hosts 2-1 in front.
Guy Bates levelled and Jens Joensen gave Runavik a 3-2 lead before Andrew Waterworth equalised on 69 minutes.
Justinussen struck late but Linfield progressed to set up a meeting with FC Spartak Trnava of Slovakia.
Warren Feeney's side are away in the first leg next Thursday with the return match in Belfast a week later.
An impressive 2-0 victory at Windsor Park gave the Irish League side a cushion going into the trip to Totfir.
Glendinning increased the aggregate margin to three when he fired home a 14th minute opener for the Blues.
However, the visitors were trailing just five minutes later as Runavik hit back through Olsen and Justinussen.
Magnus Olsen hit the Blues bar as the hosts chased a third but Linfield were next to score on 33 minutes.
Bates netted on his debut in the first leg and the former Glenavon striker made it 2-2 with a close-range finish after good work from Ivan Sproule.
Joensen's low shot seconds before the break moved Runavik back in front and Einar Hansen squandered a good chance early in the second half.
Aaron Burns set up Waterworth to level with a fine finish on 69 minutes before Justinussen completed his double five minutes from time to give Runavik victory on the night but a one-goal defeat on aggregate.