Chris Coleman's Wales travelled to Bosnia-Herzegovina looking for a point in Group B to confirm their progression into Euro 2016 in France next year.
The away side started the game in positive fashion, but found themselves behind in the second half following Milan Duric's headed effort.
Bosnia sealed the three points in injury time when Vedad Ibisevic grabbed a second late on to earn a vital win for the hosts to keep their dreams of a playoff spot alive.
As for Wales, they were lucky enough to benefit from a Cypriot victory over Israel in one of the group's other fixtures, meaning that the Dragons earned qualification despite the loss on Bosnian soil.
Here, Sports Mole runs the rule over the game at the Bilino Polje Stadium in Zenica.
Match statistics
BOSNIA-HERZEGOVINA
Shots: 7
On target: 2
Possession: 55%
Corners: 2
Fouls: 12
WALES
Shots: 14
On target: 4
Possession: 45%
Corners: 2
Fouls: 15
Was the result fair?
Both sides enjoyed impressive spells in the game, but the home side proved the more clinical of the teams as they grabbed a 2-0 victory despite only turning two efforts on target in the contest. The Bosnians rarely offered much going forward in attack and their only real sense of urgency was delivered by Miralem Pjanic, although they proved effective in the vital moments in the game to snatch two goals from set-pieces.
It appeared as though Wales were playing the perfect tactical game in the second half, before eventually being undone from dead-ball situations. Coleman will be irritated by the defeat, but it will now be one that he remembers with great joy given that it came on the same night that his country secured progression into the finals of a major tournament for the first time in 57 years.
Bosnia-Herzegovina's performance
Mehmed Bazdarevic will be delighted with his side's clinical edge in the contest and their victory has now put them firmly on course to snatch a playoff spot from Israel. For large parts of the game the home side did not appear like a team that would cause too much off a threat for Coleman's charges. Pjanic provided much of the spark for the hosts and they eventually responded to his industry by taking the lead through a brilliant header from substitute Duric.
Bazdarevic's work on the sidelines cannot be ignored either, given that his changes in the second half created relatively quick dividends as Duric was able to put them ahead and then provide the assist for his country's late second. Credit must also go to the team's defensive and midfield positioning, as they were able to nullify the threat of Bale and also crowd out the strength of Hal Robson-Kanu.
Wales' performance
This will be a tough result to take for Wales given that they had shown great promise for large sections of the clash. Coleman will have thought that he had deployed some adroit tactics as the Dragons appeared in near total control as the fixture went into the final stages, but they were undone by two-set pieces despite having been defensively sound for most of the match.
Aaron Ramsey and Bale showed glimpses of creative brilliance, although they might be a touch frustrated at how easily they were shut out by the home side's defence. A two-goal defeat perhaps suggests that Wales were well beaten, but they will argue differently. Coleman and company have been outstanding throughout the campaign and could have ended the qualification period unbeaten had they not fallen asleep at two free kicks. That said, the Dragons are now through to France next year and will be delighted with the progress made in recent years.
Sports Mole's man of the match
Milan Duric: Much of the news following the game will surround the qualification of Wales, but this victory also has huge ramifications for Bosnia. Given the victory, they are now in position to secure a playoff spot should they win in their final game and that scenario was only made possible by the brilliance of Duric. The frontman was introduced with 30 minutes to go and turned the game on its head by scoring one and creating another.
Biggest gaffe
Ramsey shone as one of Wales' brighter performers, but he really should have put the Dragons 1-0 ahead going into the break. The Arsenal man did brilliantly to get in behind the defence and then beat his retreating marker. With just the keeper to beat, he was unable to guide the ball over the line with the help of Neil Taylor, and that miss potentially changed the course of the game as Bosnia grabbed match-winning goals in the second period.
Referee performance
Spanish official Alberto Undiano Mallenco enjoyed an impressive display away in Bosnia as he allowed the game to be played without too many stoppages. The referee sought to play the advantage whenever possible in order to benefit the fluidity of the contest and the players responded by playing out an intriguing tactical contest. The official did have to reach into the book on a few occasions, but made all the right calls when required.
What next?
Bosnia-Herzegovina: Following the victory, Bosnia now have a strong chance of making it into a playoff spot come the conclusion of the 10th game of Group B. Israel's defeat to Cyprus has meant that Bazdarevic's men now hold third spot and they will be looking to cement that position with a win away at Cyprus on Tuesday.
Wales: Results elsewhere gave Wales a reprieve and they are now heading to France regardless of the defeat to Bosnia. Coleman and his charges will be playing at their first ever European Championships next summer but first they must face Andorra in Cardiff on Tuesday night.