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.
IMrj55uvz6IThe US House Ethics Committee has voted to release its report on former Republican Representative…
ABC News has agreed to pay $15 million to President-elect Donald Trump to settle a…
South Korea’s parliament has voted to impeach President Yoon Suk Yeol over his failed attempt…
Israeli war planes have carried out more than 100 air strikes in Syria on December…
President-elect Donald Trump has threatened to impose 100% tariffs on the BRICS countries if they…
Syrian troops have withdrawn from the city of Aleppo following an offensive by rebels opposed…