Bulgaria edged Spain 75-73 in Group D after outscoring their opponents 23-13 in the final quarter.
Deyan Ivanov had 22 points to pace the winners, 14 of which came in the fourth quarter.
His three-pointer with just over 3 minutes remaining cut Spain's lead from 7 points to 4, and following baskets from Asen Velikov and twin brother Kaloyan, Deyan's lay-up tied the game at 70-70.
A bucket by Kaloyan and 2 free throws from Deyan gave Bulgaria a 4-point lead with 22 seconds to play, but Spain's Sergio Llull hit a clutch three-pointer to give his team the chance to pull out a victory.
However, Zhivko Stoyanov blocked Marc Fernandez's lay-up attempt in the final second and Bulgaria came away with the win.
Ivanov also had nine rebounds for Bulgaria, Jose Angel Antelo, the Spanish center, had 17 points to lead his side.