Successive late heartbreaks have Spain in danger of possible elimination from the Rio Olympics before they clear the group stage.
Brazil dealt the two-time defending silver medalists their second upset in three days on Tuesday when Marquinhos buried a tip-in layup with five seconds to play that gave the host nation a 66-65 win - their first of the 2016 Games.
Marquinhos, an NBA draft pick in 2006 who plays professionally in Brazil, finished with 10 points and five rebounds.
Four-time Olympian Pau Gasol struggled for Spain, shooting four-for-11 from the field for 13 points.
Elsewhere in the group stages, Lithuania topped Nigeria 89-80, and Argentina moved to 2-0 when it held on for a 90-82 victory over Croatia.
Brazil's women were not as fortunate, falling to Belarus 65-63. Australia stayed perfect with an 89-71 victory over France and Turkey defeated Japan 76-62 to pick up their first win.
HIGHLIGHT OF THE DAY
Marquinhos' winner came off a put-back of a missed jumper by Marcelo Huertas. Spain had a chance to respond on the ensuing possession, but Sergio Llull's desperation jumper fell harmlessly to the floor.
MVP OF THE DAY
Turkey's LaToya Sanders poured in a Rio-high 36 points (14-for-18 from the field) and added seven rebounds and two blocks for good measure.
QUOTES OF THE DAY
"I'm very confident this situation will end with the next game. ... I will call it [the situation] challenging, not bad, but challenging. It's not bad until you're out, and we're still very in," - Spain coach Sergio Scariolo staying upbeat.
"It was a unique moment playing at home, at my home, in my city. All I wanted was to be in that moment. Every player, when he dreams about becoming a player thinks, 'I wonder if I will ever be the decisive player in a game', in a free throw or in a three-point shot. It was my big moment. That is [usually] not part of my game, I am not a guy who has a lot of points in rebounding, neither offensively nor defensively. But that was my moment and I embraced it," - Marquinhos on his game-winning shot.
In a potential preview of the men's gold medal game, the United States face their toughest test yet in Australia after two blowouts to open the tournament. Group A continues with Serbia against France and Venezuela taking on China. For the women, USA meet Serbia among three matches.