Krisztián Vadócz kept his nerve to convert a late penalty as Hungary came from behind to earn a hard-fought 2-1 victory to keep alive their hopes of a place in the UEFA European Under-21 Championship play-offs.
The midfielder coolly slotted home with eight minutes left, but it is livewire substitute József Magasfoldi that will take the plaudits after his introduction turned the game on its head. After tormenting the home defence, he finally cancelled out Adrian Olegov's early goal on 78 minutes before pouncing on a loose pass and earning the late spot-kick.
The result leaves Hungary third in Group 8, level on points with second-placed Sweden, with next Tuesday's opponents Croatia already confirmed as section winners. Bulgaria, meanwhile, remain second from bottom, but it all began very differently for the home side, who took the lead after just three minutes when PFC CSKA Sofia defender Olegov rose highest to power in a header.
Dimitar Rangelov almost doubled the lead on 12 minutes but was brilliantly denied by goalkeeper Márton Fülöp, and the save seemed to awaken the sluggish visitors. They rarely threatened, however, and Bulgaria looked on course for a rare win until the introduction of Magasfoldi.
After testing goalkeeper Emil Petrov with a stunning scissor-kick, the midfielder equalised with 12 minutes left, and then a foul on him by Petar Zanev allowed Vadócz to step up to seal the win that leaves Hungary with everything still to play for.