Spain advanced to the 5th-8th place Semi-Final Round of the U18 European Championship Men with an 83-80 victory over Italy with Daniel Perez securing the win with two foul shots with five seconds left.
Alberto Jodar paced Alejandro Martínez's side with 15 points while Toni Vicens had 14 and Ignacio Llovet and Josep Franch each scored 10 points as Spain finished the Qualifying Round Group E with a 2-3 record.
Italy dropped to 1-4 and were eliminated from the 5th-8th place Semi-Final Round, meaning Alessandro Ramagli's team cannot fight for a place at the U19 World Championship 2009.
Luca Campani hit for 22 points to lead the Italians while Pasquale Paolisso had 14 and Andrea Muner scored 11.
Spain started the better team and back-to-back baskets by Perez made it 9-2 early. And the lead grew to 17-8 with four minutes left in the first. But after Raffaele Martone scored Italy's first eight points, Muner knocked down a three-pointer and then Campani hit eight points as Italy pulled to within 22-21 after one period.
Early in the second period it was Paolisso's turn for the offense and following triples by each Riccardo Moraschini and Muner the Italians pulled ahead 42-28. But Jodar connected on seven straight points to cut the deficit to 46-37 at intermission.
Campani pushed the cushion to 50-39 before Martinez and Llovet combined to bring Spain back into the game and Franch's basket left Spain trailing just 53-50 midway through the third.
Italy, however, again went to the long ball and Andrea De Nicolao and Muner both hit three-pointers to re-establish a 63-54 advantage.
But Martínez's team finished the third period on a 10-2 run to trail just 65-64. Franch gave Spain the lead with a basket to open the fourth. And a Jorge Santana three-ball helped open a 70-67 gap.
Moraschini knotted the game again at 76-76 before Alejandro Hernandez knocked down a three-pointer. Nicolò Melli answered but Hernandez made another score to make it 81-78. De Nicolao closed it to 81-80 with more than a minute left but Perez made two foul shots with five seconds left to win the game.