Spain have qualified for the semi-finals of the U21 European Championship after beating Portugal 3-1 on Tuesday.
Atletico Madrid's Saul Niguez opened the scoring with a deflected effort after 21 minutes and Everton target Sandro Ramirez swept home Gerard Deulofeu's cross to make it 2-0 in the second half.
Bruma replied for Portugal with a superb volley from 25 yards but Inaki Williams raced clear and scored in injury-time to secure victory for Spain.
The win ensures Spain qualify as Group B winners due to their head-to-head record over Portugal, who are on three points and still in with a chance of making the semi-finals as the best second-placed team.
It was Portugal who made the brighter start as Bruno Fernandes volleyed over from the edge of the box and Daniel Podence struck the post with a low shot from around 25 yards.
But Spain scored with nearly their first attack as Saul jinked past a couple of challenges and then saw his shot deflect past Bruno Varela.
Spain continued to look threatening, with Deulofeu curling a shot over and Hector Bellerin denied by Varela after a clever through ball by Marco Asensio. Ramirez then dragged a shot wide after controlling a pass across the edge of the area from Asensio.
Portugal upped the tempo at the start of the second half as Kepa denied Fernandes before Podence curled a shot narrowly wide.
Asensio saw a powerful goal-bound effort brilliantly blocked by Edgar at the other end, before Sandro doubled Spain's advantage, sweeping home Deulofeu's cross at the near post.
Substitute Bruma replied for Portugal in the 77th minute with a superb volley from 25 yards after a cross was cleared out to him.
But Portugal could not snatch an equaliser and can now only qualify for the semi-finals as the best second-placed team.
Man of the match - Gerard Deulofeu
Spain's captain delivered when they most nedeed him. The Everton winger pulled the strings and provided many genuine attacking opportunities throughout his 82 minutes.
Deulofeu grabbed the assist for Sandro's goal, which was an accurate low cross into the Malaga striker's path.
What next?
Spain face Serbia in their final group game in Bydgoszcz on Friday while Portugal take on Macedonia in Gdynia. Both games are live on Sky Sports.