The trio Aymeric Laporte, Álvaro Morata (who also missed a penalty) and Alex Baena scored the Spanish goals at home in Córdoba.
Spain has now 14 consecutive matches without defeat. The team stands on ten points in Division A's group 2 and can at worst finish second, which gives a spot in the quarterfinals.
Denmark is second on seven points after Christian Eriksen saved a point away against Switzerland with his 2–2 goal. Serbia has four points and bottom-placed Switzerland has one point.
Portugal also had the opportunity to book a spot in the quarterfinals, but superstar Cristiano Ronaldo and his teammates were shut out away against Scotland. The match in Glasgow ended 0–0 and the Scots took their first point in Division A's group 1. Portugal tops the group on ten points – three ahead of Croatia and six points ahead of Poland.
Besides Spain, Germany is also clear for the quarterfinals. The Germans secured their spot in the finals next March on Monday.