Linfield's brave attempt to reach the Europa League group stages ended in disappointment in Azerbaijan as they lost out to Qarabag on away goals.
Trailing 3-2 from the first leg in Belfast, Qarabag took a sixth-minute lead through Jaime Romero's left-foot shot into the bottom corner.
Despite the hosts enjoying most of the possession Linfield remained resolute until Abdellah Zoubir's late goal.
Shayne Lavery rifled home in injury-time to make it 4-4 on aggregate.
The Irish Premiership champions' heroic performance at Windsor Park a week ago saw them go into the second leg with a realistic chance of becoming the first Irish League side in history to make the group stages of a European competition.
But despite a spirited display in energy-sapping humid conditions in Baku David Healy's side fell agonisingly short of an aggregate victory and landing the lucrative estimated £4m jackpot which would have come their way had they progressed.
Linfield suffered an early setback when Romero ran on to Magaye Gueye's flicked ball and beat Rohan Ferguson at his near post with an angled drive.
The home side dominated the play for the remainder of the first half but their opponents got men behind the ball and proved difficult for the Azerbaijan champions to break down.
Ferguson palmed away Michel's effort and dived at Romero's feet to deny him a second, while at the other end Bastien Hery shot straight into the arms of Vagner da Silva in Linfield's best chance of the opening period.
Just before the interval Niall Quinn's inviting left-foot free-kick flew across goal but no Linfield player was able to get the vital touch.
Soon after the hour mark Rashad Sadygov struck the post with a free-kick from just outside the area as Qarabag went in search of the goal which they hoped would kill off the tie.
Ferguson produced another fine save from Zoubir, before Healy displayed more attacking intent by introducing Kirk Millar, Andrew Waterworth and Jordan Stewart in an attempt to find an equaliser.
As the visitors pushed forward dangerman Zoubir made the most of more space afforded to him in the Linfield half, latching onto a clever through ball, then rounding Ferguson and slotting into the empty net.
Lavery, the two-goal hero in Linfield's first-leg win, grabbed a consolation goal in added time when he chested the ball down and fired into the top corner right-footed with the aid of a deflection.
Linfield's thrilling European odyssey comes to an end while a relieved Qarabag go into Friday's draw for the group stages.
Line-ups
FK Qarabag
Formation 4-2-3-1
- 13da Silva
- 5Medvedev
- 4Mammadov
- 14Sadiqov
- 3Ferreira SilvaBooked at 63mins
- 8Marcos MaderaBooked at 86minsSubstituted forQuintana Sosaat 90+1'minutes
- 20Almeida de OliveiraBooked at 82mins
- 11Emreli
- 9Romero
- 17ZoubirSubstituted forAbdullayevat 90+1'minutes
- 99GueyeSubstituted forQarayevat 85'minutesBooked at 90mins
Substitutes
- 2Qarayev
- 6Slavchev
- 7Abdullayev
- 10Quintana Sosa
- 12Mahammadaliyev
- 23Rherras
- 30Huseynov
Linfield
Formation 4-2-3-1
- 1Ferguson
- 47Casement
- 2StaffordBooked at 61mins
- 6Callacher
- 16Clarke
- 22Mulgrew
- 20FallonSubstituted forWaterworthat 78'minutes
- 9CooperSubstituted forStewartat 81'minutes
- 8Héry
- 31QuinnSubstituted forMillarat 78'minutes
- 14Lavery
Substitutes
- 7Waterworth
- 10Stewart
- 12Millar
- 17Kearns
- 23McGivern
- 27Mitchell
- 40Moore
- Referee:
- Sergei Ivanov
- Attendance:
- 18,349