LONDON -- LeBron James provided the big plays down the stretch to help the United States escape with a 99-94 win over Lithuania and remain unbeaten -- barely -- at the men's Olympic basketball tournament Saturday.
There was no such escape for Spain, silver medalist four years ago in Beijing and seen by many as a likely challenger for the star-studded American team in the final.
Russia's 77-74 victory over the two-time European champion meant that the Russians secured top place in Group B -- and avoided a potential matchup with the heavily favored Americans until the gold medal game.
Timofey Mozgov made the tiebreaking dunk with 18 seconds left and Vitaliy Fridzon, the hero of Russia's victory over Brazil on Thursday, made the clinching free throws with 4.8 seconds left after the Russians had charged back from an 18-point deficit. Fridzon scored 24 points.
"We won the group today," Russia coach David Blatt said. "It's a good feeling. I'd hoped that we would finish in one of the top three spots, to be honest with you, just so that we could avoid the Americans team in the quarters."
The Russians did even better. Any meeting now -- assuming the Americans win Group A as expected -- wouldn't happen until Aug. 12 in a rematch of the 1972 title game.
"That would be interesting, wouldn't it? It's a long way, though, but again, it'd be interesting," said the American-born Blatt.
It was Spain's first loss in the Olympics to a team other than the U.S. since 2000, and it and now risks having to meet the Americans in the semifinals.
Two days after running and gunning to a record-shattering 83-point win over Nigeria, the Americans had to come back in the fourth quarter over a fearless Lithuania team that had the world's best squad in serious trouble until the closing minutes.
James scored 9 of his 20 points in the final four minutes for the U.S., Carmelo Anthony added 20 points, Kevin Durant 16 and Chris Paul added seven rebounds, six assists and four of the U.S. team's 17 steals.
Linas Kleiza scored 25 to lead Lithuania, which was up 84-82 with 5:50 to play. After the U.S. took a three-point lead, Lithuania would not go away and pulled within 87-86 on Darius Songaila's bucket with 4:12 left.
That's when James, who has already won an MVP trophy and NBA title this year, took control.
He knocked down a 3-pointer from the top of the key, and after Paul stole the inbound pass, James took a pass down the right side and delivered one of his trademark dunks, a basket that brought the American players off the bench and seemed to restore world basketball order.
After a basket by Deron Williams -- on a possession Paul kept alive with an offensive rebound -- James followed a Lithuania turnover with a left-handed layup, giving the U.S. a 97-88 lead. The Americans remained unbeaten -- though no longer untested.
"You want to get tested. The best teams want to be tested. We love the competition," James said. "I think we've got some of the greatest competitors in our league, in this world, so you want to have a game where you feel like you were tested, and we had that today."
Anton Ponkrashov scored 14 points and Mozgov had 12 for Russia, which trailed 20-2 in the first quarter and still trailing by nine with under 4½ minutes left.
Pau Gasol scored 20 points for Spain (3-1), but missed the first of two free throws with 5.2 seconds left and the Spaniards trailing by two.
Marc Gasol and Rudy Fernandez each had 10 for the Spaniards in the first meeting since Russia stunned Spain, then the reigning world champions, 60-59 in the 2007 European championship game.
Spain used star guard Juan Carlos Navarro for just the second time in the Olympics as he recovers from a left-foot injury.
Russia didn't even qualify for the Olympics until a last-chance tournament in July.
Marquinhos Vieira scored 14 points and Leandro Barbosa added 13 for Brazil to rout China 98-59 and reach the quarterfinals from Group B.
Brazil is 2-2 in Group B, while China fell to 0-4.
In the early game, Tony Parker scored 22 points and Nicolas Batum added 19 as France beat Tunisia 73-69 for its third straight victory.