Edin Dzeko scored his second goal in the 90th minute. But it wasn't enough for the 13th-ranked Dragons, who lost for the first time in nine games.
The U.S. winning streak, the longest currently in the world, appeared to be jeopardy after the Americans fell behind 2-0 before halftime. But Altidore set up Johnson's goal in the 55th minute, controlling a long chip shot from Michael Bradley with a slight touch of his left foot. The ball fell right at Johnson's feet and, with goalkeeper Asmir Begovic out of the net to block Altidore, Johnson neatly tapped the ball into the empty net to cut Bosnia's lead to 2-1.
Four minutes later, Altidore evened things up.
Fabian Johnson slalomed through a crowd of Bosnian defenders, chipping the ball to Altidore. He took one shot and buried a left-footed shot from 16 yards that the diving Begovic had no chance to stop. It was Altidore's fifth goal in as many games, breaking the previous mark he'd shared with Johnson, William Looby, Eric Wynalda, Brian McBride and Landon Donovan.
"We came in (at halftime) and said, 'Listen we can beat this team,'" Altidore said. "We came in and said, 'We have more weapons, we're just as confident as they are. We just have to put more passes together and be more confident.' And you saw that in the second half, we created so many chances."
And turned them into goals.
The Americans were awarded a free kick in the 84th minute when Edgar Castillo was tripped by Miroslav Stevanovic. Altidore lifted the ball over the wall of Bosnians and into the back of the net. Two minutes later, he finished off the hat trick with a shot from about 8 yards out.
The win is sure to be a boost for the Americans when they resume World Cup qualifying next month. The U.S. travels to Costa Rica on Sept. 6, then returns home to face archrival Mexico four days later in Columbus, Ohio, in a game that could secure the Americans a spot in next year's World Cup in Brazil.
"This team is coming together at the right time," Altidore said. "We have things to work on, but it looks like everything is coming together. The bigger picture is the World Cup and we want to be ready for that."
Bosnia, meanwhile, is looking to earn its first trip to the World Cup. The Dragons sit atop Europe's Group G with a three-point lead over Greece.
Some have dismissed the U.S. winning streak, pointing out that 10 victories had come on home soil and all but one were against opponents from the North and Central America and Caribbean nations. The Americans didn't put up much of an argument early, falling behind in the eighth minute when Johnson lost the ball about 23 yards out. The Bosnians quickly pounced on it and it was slotted to Dzeko, who picked it up just inside the 18-yard box.
His first shot deflected off Howard, but Dzeko was right there to collect the rebound and Howard had no chance to stop his left-footed shot.
The Dragons' second goal was even more painful considering it came from Vedad Ibisevic, who spent part of his childhood in St. Louis and whose family still lives in the Midwestern city. Taking advantage of a beautiful cross by Zvjezdan Misimovic in the 30th minute, Ibisevic redirected the ball with a powerful whip of his head and sent it whistling past the outstretched fingers of a diving Tim Howard.
"It is just a friendly," said Howard, who made a spectacular one-handed save in the 67th minute that helped preserve the win. "But you never discount a really good performance. We'll take it. We'll build from it and we'll grow. This is going to do us a world of good going down to Costa Rica."