Hungary breathed some life into their EuroBasket 2009 qualifying campaign by edging high-flying Bulgaria 87-86 in Group A on Saturday.
Marton Fodor, who had 17 points for Hungary, scored his biggest three right before the end with a shot from behind the arc for the final outcome.
Fodor was four of eight from three-point range and Hungary 13 of 28.
Bulgaria, who began with three straight wins, fell to 3-2 but are still in second place behind Serbia.
Hungary led 47-43 at half-time but then endured a nightmare start to the third quarter when Bulgaria reeled off 12 straight points for a 55-47 advantage.
Filip Videnov and Dimitar Angelov did all of the scoring for the Bulgarians in the run.
Hungary fought back to trail 72-70 at the end of the third quarter, only for Bulgaria to keep their noses in front for most of the fourth.
When Hungary's Marton Bader made one of two at the free throw line with 2:45 remaining, the game was tied at 84-84.
With 1:16 to play, Ivanov made a lay-up to put the Bulgarians back in front but Fodor's late three-ball clinched the victory in Salgotarjan for Hungary who are now 2-3.
Hungary guard Istvan Nemeth was outstanding on offense, making four of six from behind the arc on his way to a team-high 19 points.
Erno Sitku scored 13 and grabbed five rebounds.
For Bulgaria, Angelov had 21 points, Deyan Ivanov 16, Todor Stoykov 15 and Filip Videnov 12.
Lajos Mészáros, Hungary coach:
"The team was mentally very strong, everyone added something to this victory."
Márton Fodor, Hungary player:
"I could see, that Stoychkov was flying towards me, I must confess that my main goal to draw a foul. I have never had many similar possibilities [to decide a game] so far. I guess, I will remember forever, how the team was celebrating after the game."
Pini Gershon, Bulgaria coach:
"We came close to winning this game, but at crucial moments we made some mistakes. This is the game!"
Dejan Ivanov, Bulgaria player:
"We are disappointed that we lost, especially after we had controlled the game for most of the time. But at the end the home team had more luck."