Match ends, Bosnia and Herzegovina 2, Wales 0.
Wales reached their first major tournament finals in 57 years in bizarre circumstances as they qualified for Euro 2016 despite defeat in Bosnia-Herzegovina.
Needing a point to end a wait stretching back to the 1958 World Cup, Chris Coleman's side were beaten by Milan Djuric and Vedad Ibisevic's second-half goals.
But they went through anyway thanks to Cyprus' 2-1 victory in Israel, which sparked wild celebrations from the away fans in Zenica.
Wales' first defeat of the campaign saw them overtaken at the top of Group B by Belgium, who qualified with a 4-1 win in Andorra.
Those success-starved supporters can now look forward to next summer's tournament in France, and consign half a century of heartache to history.
Littered with false dawns and squandered opportunities, Welsh football has come to be defined by agonising failure - but not any more.
The current generation of Wales players grew up watching agonising near-misses. Paul Bodin struck the bar with a penalty in a defining World Cup qualifying defeat against Romania in 1993, while Mark Hughes' side lost a European Championship play-off against Russia 10 years later. It is the anguish of the past which has inspired this generation.
Delight in defeat
A year ago, Wales and Bosnia were inseparable in an absorbing goalless draw in Cardiff, and Coleman's men knew a repeat would clinch Euro 2016 qualification.
Top seeds at the start of the campaign, Bosnia needed a win to keep alive their play-off hopes but were without their captain and all-time leading scorer Edin Dzeko.
The Manchester City striker, on loan at Roma, failed to recover from a knee injury but, despite his absence, Bosnia began confidently with another Roma player, Miralem Pjanic, orchestrating matters in midfield.
Coleman had said beforehand Wales would "take the game to Bosnia" and, although there was attacking intent from the visitors, they were deprived possession for long periods.
Their best chance came moments before half-time as Aaron Ramsey jinked his way to within a yard of goal - but his and Neil Taylor's scrambled close-range efforts were thwarted by Bosnia goalkeeper Asmir Begovic.
The hosts improved in the second half and, roared on by their hostile crowd, took the lead as Djuric's header looped over Hennessey.
Bosnia sealed victory as Ibisevic tapped in from close range, and Welsh attention turned to the match between Israel and Cyprus.
Cyprus fans for the night
While a point in Zenica would guarantee their place in France, Wales also knew they would qualify if Israel failed to win their final two fixtures against Cyprus and Belgium.
Israel were expected to beat Cyprus but, after 58 minutes, fell behind to a goal from Dossa Junior.
When news of that strike reached the 750 Wales fans in Zenica, their little pocket of the vociferous Bilino Polje Stadium erupted.
Delirium soon turned to anxiety when Israel equalised and Djuric headed Bosnia in front, much to the deafening delight of the home crowd in Zenica.
But there was a sense of mutual joy moments later, as Walsall defender Jason Demetriou put Cyprus back in front against Israel and put Wales back on the brink of history.
An almighty party in Cardiff
Regardless of the result against Bosnia, Wales knew they had the insurance of Tuesday's home game against an Andorran side without an away win in their competitive history.
The final fixture of a momentous campaign, the match at the Cardiff City Stadium has long been earmarked as the opportunity for Wales fans to welcome home their heroes with an almighty party.
The result will be academic now that qualification has been secured but, having suffered a first defeat of the campaign in Bosnia, Wales can end it on a high and toast their historic achievement in front of a delirious home crowd.
Reaction - 'See you in France!'
Wales manager Chris Coleman: "I've wanted this not only as a player and manager but as a fan, as a child growing up.
"We didn't know what the other result was but now we do and wow, I can't explain how it feels. We got a bit flustered in the second half but in the circumstances, you can understand that.
"It is a dream come true. All the players from my generation, and generations before, nearly got there, and it was really tough. But this group have gone that extra yard."
Wales forward Gareth Bale: "This is right up there in my career. It was a dream from when I was a small child to play in a major tournament. It doesn't stop here. We have business to do in France.
"We can breathe a sigh of relief and enjoy the occasion. We can now test ourselves against the best."
Wales midfielder Aaron Ramsey: "What a great moment for Welsh football. What an achievement to have made history, we are finally going to a major tournament.
"This group of players is quite special. It didn't quite happen tonight, but the togetherness, we've been really hard to beat.
"We're only a small nation, but we've done it. We're over the moon. Thanks to all the supporters. See you in France!"
Wayne Hennessey (6), Chris Gunter (6), Ashley Williams (7), Ben Davies (6), Jazz Richards (6), Joe Allen (8), Joe Ledley (7), Neil Taylor (8), Aaron Ramsey (6), Gareth Bale (7), Hal Robson-Kanu (7).
- 1BegovicBooked at 85mins
- 15SunjicBooked at 85mins
- 4SpahicBooked at 42minsSubstituted forCocalicat 45'minutes
- 21HadzicSubstituted forBicakcicat 89'minutes
- 19ViscaSubstituted forDjuricat 60'minutes
- 7AllenSubstituted forEdwardsat 85'minutes
- 16LedleySubstituted forVokesat 75'minutes
- 3TaylorBooked at 84mins
- 9Robson-KanuSubstituted forChurchat 84'minutes
- 12Fon Williams
- Alberto Undiano Mallenco
- Shots on Target
Second Half ends, Bosnia and Herzegovina 2, Wales 0.
Goal! Bosnia and Herzegovina 2, Wales 0. Vedad Ibisevic (Bosnia and Herzegovina) right footed shot from very close range to the bottom right corner. Assisted by Milan Djuric following a corner.
Attempt missed. Milan Djuric (Bosnia and Herzegovina) left footed shot from a difficult angle on the left misses to the right. Assisted by Vedad Ibisevic following a corner.
Substitution, Bosnia and Herzegovina. Ermin Bicakcic replaces Anel Hadzic.
Corner, Bosnia and Herzegovina. Conceded by Dave Edwards.
Attempt blocked. Miralem Pjanic (Bosnia and Herzegovina) right footed shot from outside the box is blocked. Assisted by Sejad Salihovic.
Attempt saved. Sam Vokes (Wales) header from the centre of the box is saved in the top centre of the goal. Assisted by Aaron Ramsey with a cross.
Corner, Wales. Conceded by Miralem Pjanic.
Attempt blocked. Gareth Bale (Wales) right footed shot from outside the box is blocked. Assisted by Neil Taylor with a headed pass.
Attempt missed. Dave Edwards (Wales) right footed shot from outside the box is too high. Assisted by Simon Church.
Asmir Begovic (Bosnia and Herzegovina) is shown the yellow card.
Toni Sunjic (Bosnia and Herzegovina) is shown the yellow card.
Substitution, Wales. Dave Edwards replaces Joe Allen.
Substitution, Wales. Simon Church replaces Hal Robson-Kanu.
Aaron Ramsey (Wales) is shown the yellow card for a bad foul.
Sejad Salihovic (Bosnia and Herzegovina) wins a free kick in the defensive half.
Foul by Aaron Ramsey (Wales).
Delay over. They are ready to continue.
Delay in match Sejad Salihovic (Bosnia and Herzegovina) because of an injury.