Ukraine met stiff resistance but finally put away the visiting Czech Republic in a do-or-die showdown in the EuroBasket Relegation Round on Thursday.
The Ukrainians prevailed 82-70 to finish 4-2 and secure their Division A status.
Defeat for the Czechs, who played at EuroBasket 2007, has sent them crashing into Division B with a 3-3 record.
In a gripping encounter, Ukraine rode a strong effort from Sergiy Lishchuk to open a 28-19 lead.
Lishchuk poured in 14 of those points for his team.
The hosts went in front by as many as 11 in the first half but didn't put Michal Jezdik's team away.
Instead the Czechs ended the second quarter with a 5-0 run and closed the gap to 36-30.
Oleksiy Pecherov had 12 of his game-high 21 points in the first half for Ukraine.
When play resumed, Czech baskets from Tomás Satoránský and Ladislav Sokolovsky trimmed the deficit to 36-34 and they eventually went in front after a jump shot by David Jelinek made it 39-38.
The lead changed hands 10 times over the next several minutes before a crucial three plays made by Ukraine's Dmytro Gliebov.
The 1.98m small forward caught a pass from Pecherov and made a jumper with 7:42 remaining to give his side a 60-59 advantage.
He then intercepted a pass from Petr Benda and went in for a lay-up for a three-point edge.
Satoránský split a pair of free-throws for the Czechs before Ukraine's Maksym Vilkhovetskyi drilled a three-pointer.
Jan Vesely drilled a jump shot for the Czech Republic but Ukraine replied with an 8-0 run that included a Gliebov basket, a three-point play from Pecherov and a three-pointer from Sergiy Gladyr.
That gave the home side a 73-62 lead with 3:44 remaining and Jezdik's team never recovered, getting no closer than seven points the rest of the way.
Ukraine Head Coach Valentyn Melnichuk:
"I have to congratulate you all with us keeping our place in Division A. I also have to say 'I'm sorry' to all those people who wanted us to be relegated. I'd like to thank all the players, the coaching staff, our trainer and doctor.
"I also have to thank Sergiy Lishchuk, who despite all his injuries came out and helped. I hope he signs a great contract and stays healthy the rest of the way.
"The task of us winning three games at home and one on the road was accomplished. This was the most difficult tournament in my life and I have to say I am pleased to finish my coaching career on such a high note. I am not going to coach a national team ever again."
Ukraine Player Sergiy Lishchuk:
"I want to congratulate all the fans who came to support us. We are very happy we won the game but at the same time we are disappointed that we, the team that played in EuroBasket four years ago, had to fight four our survival. Still, these games showed we have very talented young players who should bring us back there again."
Czech Head Coach Michal Jezdik:
"It was a very difficult game because we played away. The chances were 60% for them and 40% for us. We did a very good job in the second and third quarters, but missed easy layups later on which Ukraine's experienced players took advantage of. I have to congratulate the home team."