After a goalless first-half, the game burst into life in the final 25 minutes.
Spain took the lead through Mikel Oyarzabal, only for Karim Benzema to score a beauty moments later.
Kylian Mbappe then scored a controversial winner for his side.
The Frenchman ran through on goal and made no mistake when one-on-one with Unai Simon.
Replays showed that Mbappe was in an offside position when Theo Hernandez passed to him.
VAR looked at the incident and decided that the Frenchman was indeed onside.
View the moment below...
There was uproar that the goal was allowed to stand but, according to the rule book, the right decision was made.
Eric Garcia got the slightest of touches on the ball before it reached Mbappe.
Per ESPN editor Dale Johnson, that touch meant that the right call was made.
Johnson explains that because Garcia made a deliberate play for the ball, his touch resets the offside phase ultimately meaning Kylian Mbappe onside.
Does Bruno Fernandes deserve a Ballon d'Or vote? | The Football Terrace
Should Garcia have missed the ball completely, Mbappe would have been ruled offside.
It's certainly a controversial rule and one that Sergio Busquets expressed his unhappiness with after the game.
He said, per journalist Guillem Balague: "The referee told us that Eric Garcia wanted to play the ball and that kills the offside...
"But he wanted to play the ball because the ball would have reached Mbappe who was offside! It doesn't make sense!"