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.
Renato Sanches replaced Diogo Jota for Portugal while Jonny and Dani Ceballos came in for Jose Luis Gaya and Denis Suarez for Spain.
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.
Spain: Arrizabalaga (7), Bellerin (8), Mere (6), Vallejo (7), Jonny (6), Deulofeu (8), Saul (8), Llorente (6), Ceballos (7), Asensio (8), Sandro (8). Subs: Williams (8), Suarez (6), Merino (5)
Portugal: Bruno Varela (6), Joao Cancelo (7), Edgar Ie (5), Semedo (5), Rodrigues (5), Joao Carvalho (6), Neves (5), Sanches (6), Goncalo Guedes (5), Bruno Fernandes (7), Daniel Podence (7). Subs: Paciencia (6), Horta (6), Bruma (7)
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.
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.