The defender put into his own net during injury time, after Julio Cesar's error appeared to have clinched the Europeans a deserved draw in Switzerland
The Inter keeper had previously spilled a straightforward effort from Vedad Ibsevic and could only watch as the ball finished in the net, cancelling out an earlier effort from Marcelo which had given Mano Menezes' team the advantage in the opening exchanges of the match.
Playing in front a deeply partisan crowd in favor of the European side, Brazil nevertheless started on the front foot, and with just three minutes on the clock took the lead with a delightful goal. Pressure on the Bosnian backline paid off when the ball ended at Dani Alves' feet just outside the area, and a sweeping pass found his fellow full back Marcelo free and charging towards goal.
The Real Madrid man barely broke his step as he blasted past a helpless Asmir Begovic for his third international goal.
The strike appeared to be the cue for the Selecao to take control of the game, but Bosnia had clearly not read the script; although it was aided by some disastrous defending from the South Americans. David Luiz gave possession away cheaply in his own half, and a tame shot by Vedad Ibisevic wriggled past Julio Cesar for the equalizer.
Mano Menezes' men struggled with a Bosnia team which was determined to use its physicality to impose itself on the game. With 20 minutes played, however, it really should have been 2-1. An exquisite ball from Ronaldinho found Leandro Damiao, and after the Internacional youngster saw his effort parried by Begovic, Hernanes was denied the rebound by a superb last-ditch tackle from captain Emir Spahic.
At the other end Edin Dzeko gave the Brazil defense serious problems after a slow start, and both he and Roma starlet Miralem Pjanic could have added a second for the Europeans as the game went into halftime still deadlocked.
Having been relatively quiet before the break, Neymar called Begovic into action following the restart with a decent effort from distance, but the goalkeeper saved comfortably and held onto the ball.
The Brazilians' patient approach play contrasted sharply with the smash and grab football played by Bosnia, and both ends saw action; Mismimovic flashing a chance just past the left post as the Europeans pushed for a famous victory.
Hernanes was unlucky to see his header fizz past the post after an excellent cross from Marcelo, but it was a rare glimpse of quality from a Brazil side that appeared to be meandering towards a draw. A brilliant pass from Elias, however, should have supplied the second, but after making space in the box Neymar shot straight at Begovic to waste a golden opportunity.
Just as it appeared that Bosnia would hold on for the draw, Sasa Papac ended his side's hopes. Substitute Hulk fired strongly across the area, and the defender deflected the ball past his own keeper to the obvious delight of the Brazil team, which snatched victory in the final minutes of a tense encounter.