Spain broke open a fierce defensive battle in the final minute to beat France 66-59 and reach the semi-finals of the Olympic men's basketball tournament in a bad-tempered contest that threatened to turn into a brawl.
Back-to-back fouls for unsportsmanlike behaviour were assessed against France's Ronny Turiaf and Nicolas Batum after hard hits at the end of the game, and players from both teams had to be restrained by officials from going after each other.
- London Olympics 2012 - Complete coverage
The victory put Spain into the semi-finals against Russia, who beat Lithuania 83-74 in the opening quarter-final.
Spain and Russia will meet on Friday with the winners advancing to the gold medal game and the losers playing for bronze on Sunday.
Marc Gasol led Spain with 14 points, while Tony Parker and Boris Diaw scored 15 points apiece to pace France.
Defending champions the United States play Australia, and South American rivals Brazil and Argentina meet in Wednesday's later quarter-finals.