Riot police fired tear gas as demonstrators threw missiles near the Maracana football stadium.
President Dilma Rousseff did not attend the match. She was booed at the opening of the tournament.
The protests started nearly a month ago, sparked by transport fare rises, but quickly encompassed other issues.
The main grievances are over the costs of staging the World Cup, corruption and demands for better health, education and transport.
Earlier on Sunday a group of demonstrators tried to storm a Brazilian Football Association (CBF) building in Rio. But police kept them back and the group settled outside the building.
The protesters demanded the resignation of CBF president Jose Maria Marin, who has been accused of incompetence.
In a separate protest, several thousand people marched on Maracana stadium banging drums.
They demanded free public transport, carrying placards reading “FIFA – you pay the bill”. The demonstrators also called for and end to corruption and the resignation of the Rio State governor.
Minutes before the game began, small groups of protesters threw rocks and firecrackers at police lines.
Security forces responded with tear gas and sent armored vehicles to disperse the demonstrators. There were no further incidents during the game – which saw Brazil beat Spain 3-0.
The wave of protests began nearly a month ago in the city Sao Paulo after bus fares were increased by 10%.
But after heavy-handed police action, it spread to other cities and mobilized public opinion.
The rises in Sao Paulo and many other Brazilian cities were revoked after two weeks of protests.
By then, the demonstrations had turned into a nationwide movement for better education, healthcare and transport.
IMrj55uvz6IAt least 158 people have died in Spain's worst flooding disaster in generations. On October…
Google has been fined two undecillion (a two followed by 36 zeroes) roubles by a…
Embarking on a home remodel is an exciting journey, promising enhanced comfort, increased property value,…
The US presidential candidates continued to campaign across key swing states on October 20. Footage…
Elon Musk has said he will give away $1 million a day to a registered…
India and Canada have decided to expel their top envoys along with other diplomats as…