The host nation took advantage of their home crowd to break the world champion Spainish side’s 29-game winning streak with two goals from Fred and a cracker from Neymar.
The damage was already done when Gerard Pique was sent off for a foul on Neymar when he was the second last defender.
Spain, despite being the form nation of recent years, haven’t beaten Brazil in a competitive match since 1934.
The victory was marred by a police clash with about 5000 protesters near the stadium.
Sky News reports Molotov cocktails were thrown at officers before the match about a mile from the ground.
Police used tear gas and shock grenades in response.
Image via Getty