It was Spain's first defeat in the group in five games, and one which exposed their defensive frailty from set-pieces.
"In two set-piece situations, which will be important at the World Cup, their goals arrived," said Villarreal defender Pau Torres.
"We have to improve on that."
Spain never looked comfortable in the game, a far cry from the team which reached the Euro 2020 semifinals and were defeated on penalties by Italy.
Luis Enrique selected six Barcelona players in his starting line-up, including the regular midfield trio Xavi Hernandez utilises at Camp Nou, in Pedri, Gavi and Sergio Busquets.
Ferran Torres was another of the Barca clan, part of a three-pronged attack alongside Real Madrid's Marco Asensio and Paris Saint-Germain's Pablo Sarabia.
None of the three have enjoyed regular football with their clubs this season but were given Luis Enrique's trust. They did not repay it in the first half, with Spain anaemic in attack and asleep at the back when it mattered most.