Bosnia and Herzegovina's veteran striker Edin Dzeko scored a late equaliser before his side beat Wales 4-2 on penalties to reach the World Cup playoff finals on Thursday after a 1-1 draw.
Wales winger Daniel James opened the scoring for the hosts in the 51st minute after racing on to a loose ball and powering a thunderous 25-metre shot past Bosnia keeper Nikola Vasilj.
Advertisement
Bosnia came alive after that though and home keeper Karl Darlow made an incredible save to keep out a close-range header by Ermedin Demirovic but could do nothing as the 40-year-old Dzeko glanced in an 86th-minute equaliser.
Wales dominated extra time but could not find a winner and in the end it was Bosnia's teenager Kerim Alajbegovic who held his nerve to seal the shoot-out with an ice-cool spot kick past Darlow.
Bosnia's fans celebrated loudly and they can now look forward to a home clash against Italy next Tuesday in the Path A final to secure a place at the World Cup for the second time.
It was a familiar heartache for Wales two years to the day that they lost a Euro 2024 playoff final on penalties against Poland and there was desolation in the stands at the end.
Leeds United winger James missed the decisive penalty against Poland two years ago but it looked as though he had gained redemption with a magical goal.
Had his deflected effort not bounced down off the underside of the crossbar soon afterwards, Wales would surely have gone on to set up a home clash with Italy.
But the technically-gifted Bosnians grew in belief and as the minutes ticked down they began to create chances with Alajbegovic at the heart of his side's attacking threat.
When he swung over a corner it was former Manchester City striker Dzeko who showed his class to peel off his marker and glance an unstoppable header past Darlow.
Dzeko was taken off before the start of extra time and became involved in a heated row with Wales coach Craig Bellamy as the tension mounted in extra time.
Harry Wilson, who had also hit the woodwork early in the first half, had a glorious chance to seal it for Wales but his goalbound shot was headed clear by Tarik Muharemovic.
It looked good for Wales when Darlow saved the first spot kick from Demirovic but Brennan Johnson blazed his effort over the bar and Nico Williams saw his penalty saved by Vasilj.
It was then left to Salzburg's Alajbegovic to clinch it for the visitors who are now unbeaten against Wales in five games.