Ched Evans' goal two minutes from time handed Wales Under-21s a fifth straight win in their European Championship qualifying campaign.
Boubacar Dialida Diabang gave the home side a second-half lead, before Simon Church looked to have saved a point in the 86th minute.
But Evans, currently on loan at Norwich from Manchester City, secured a win that guarantees the Welsh youngsters will remain top of Group 10 going into their double-header against main rivals Romania.
Manager Brian Flynn brought in Tottenham youngster Chris Gunter at right-back for Darcy Blake in the only change from last month's 4-0 win in Malta.
Wales had hammered Bosnia 4-0 in the reverse fixture at the Racecourse Ground last November, but the hosts' pacy attack was a major threat early on.
Wrexham's Mike Williams had a first-half 'goal' ruled out for shoving at a Joe Jacobson corner as the opening period ended goalless.
It looked set to be a costly decision when the Bosnians took the lead in the 59th minute. Welsh goalkeeper Owain Fon Williams should have done better with Diabang's low 20-yard shot - but it somehow squirted from his grasp and into the net.
The goalkeeper's embarrassment was eased when Church drilled home the equaliser, and Evans then clinched the win with a clinical finish for his seventh of the campaign.
The victory in Sarajevo leaves Flynn's team with a good chance to qualify for the tournament finals in Sweden in 2009.
Teams
Bosnia-Herzegovina U21: Buric, Colic, Benovic, Cejvanovic,
Covic, Likic, Jelic, Aganovic, Zec, Dialiba, Zivkovic.
Subs Not Used: Sehic, Handzic, Puric, Masic, Papaz, Huseinovic,
Stokic.
Goals: Dialiba 58.
Wales U21: fon Williams, Gunter, Rhys Williams, Mike Williams,
Jacobson, Allen (Brown 77), Ramsey, MacDonald, Collison, Evans,
Vokes.
Subs Not Used: Taylor, Basey, Bradley, Church, Edwards, Wilson.
Booked: Vokes.
Goals: Church 86, Evans 88.
Ref: Alexey Kulbakov (Belarus).