Sweden put up a superb fight but Hungary won the day to secure their place in EuroBasket Division A while condemning the Scandinavians to relegation.
The Hungarians led just 57-54 with a little more than six minutes remaining but gradually pulled away for a 75-64 triumph.
Istvan Nemeth led a balanced scoring attack with 16 points.
|Istvan Nemeth and Hungary will remain in Division A.|
The victory means Hungary, though they missed out on reaching the EuroBasket in Spain, will have a chance to qualify for the tournament in two years when the event is staged in Poland.
As for Sweden, a team that played in EuroBasket 2003 as hosts, they will now have to try and win promotion.
Denmark were also relegated after their losses to Sweden on Wednesday and Hungary on Thursday.
Sweden still only trailed 64-59 with 2:38 remaining after a lay-up by Joakim Kjellbom.
But Hungary's Marton Bader scored at the other end and was fouled on the play.
After a Swedish timeout, Bader went to the line and converted the three-point play for a 67-59 lead.
Olivier Olunga gave the Swedes hope with a lay-up, but Csaba Ferencz immediately replied for Hungary with a basket to restore the eight-point lead.
Sweden resorted to fouling and Hungary added to their lead with six made free throws.
Kenny Grant's three-pointer at the death finished the scoring for Sweden.
The Swedes did very well to keep their composure after falling behind 28-17 early in the second quarter.
They stunned their opponents by going on a 12-0 run to lead 29-28.
Nemeth and Tamas Kaman stopped the bleeding for Hungary, though, with back-to-back three-pointers to send their side to the break with a 34-29 advantage.
Sweden would battle back again and move in front at 41-39 after a Per Ringstrom three-ball with 3:44 to go in the third quarter.
Ringstrom had been outstanding, with that basket raising his tally to 14.
He would not score again.
And Sweden were unable to press home the advantage, with Hungary ultimately prevailing after a strong fourth quarter.
The Hungarians buried nine of 18 (50%) shots from three-point range, with Nemeth two of five (40%).
Kaman had 13 points for Hungary while Kjellbom had a game-high 18 points in defeat.