Zvjezdan Misimovic struck twice as Bosnia-Herzegovina came from behind to maintain their 100% start to their World Cup qualifying campaign.
The Dinamo Moscow midfielder proved the central figure in a spirited fightback as Latvia initially threatened to pull off a shock in Zenica.
It was they who took a fourth-minute lead when Kaspars Gorkss stabbed Oskars Klava's corner home from six yards, but the visitors' joy was short-lived.
Misimovic levelled from the penalty spot within seven minutes after Manchester City striker Edin Dzeko has been fouled by Ritus Krjauklis.
Dzeko passed up a glorious opportunity to put his side ahead for the first time two minutes before the break when Latvia goalkeeper Andris Vanins blocked his close-range effort.
However, they did take the lead seconds later when Roma's Miralem Pjanic converted the City striker's pass from 12 yards.
Misimovic claimed his second goal of the game nine minutes after the restart when he made the most of Pjanic's pass from similar range, and although Dzeko was denied by a post with 15 minutes remaining, he cemented the win in injury time when he finished right-footed from the left side of the penalty area to cap a good night's work.