Protesters have clashed with police at a parade to mark Brazil's Independence Day and outside a stadium where an international football match had just ended.
Thousands of people across the country took to the streets to voice their anger at shabby public services and political corruption.
In Rio de Janeiro, around 500 masked protesters took over viewing platforms set up to watch the annual military parade, sending families fleeing.
Police used tear gas and stun guns against the protesters and arrested scores of people, ensuring the parade was not disrupted.
"It was frightening. There was a wave of masked demonstrators dressed in black," Rosangela Silva, who took a niece to watch the parade, told Reuters.
"I never thought I would go through this. My God! In such a beautiful country," said 63-year-old Josefa da Silva, who had been affected by tear gas.
In the country's capital, Brasilia, more than 1,000 protesters marched to the country's senate building, where they clashed with police.
Some then went on to the city's new $600 million Mane Garrincha stadium, where a friendly match between Brazil and Australia had just been played.
Police used tear gas and batons to prevent the protesters getting into the half-empty stadium, and made 26 arrests.
Some claimed that officers had used excessive force.
"They never spoke to us. They came in in great numbers and began throwing tear gas canisters," student Leticia Hellen told Agencia Brasil.
The protesters had only been allowed to march after the Independence Day parade along Brasilia's main avenue, led by President Dilma Rousseff, had ended.
In response to the unrest, Rousseff said there was "still a lot to be done" in Brazil and that there were "urgent problems to be addressed and the population has the right to demand changes".
But she said the country had "progressed as never before in the last few years".
In Brazil's largest city, Sao Paolo, a demonstration by 2,000 people largely passed off peacefully, though arrests were made towards the end of the day when masked youths attacked shops and banks.
In Fortaleza and Curitiba, where protests were also peaceful, police said they arrested youths with gas masks, slingshots and stones in their backpacks.
Yesterday's protests were smaller than those earlier in the year, with organisers claiming many had been put off attending by the violence that had erupted previously.
In June, tens of thousands took to the streets, with demonstrators initially protesting against a hike in public transport fares, then calling for the removal of corrupt politicians and venting fury at what they claimed was excessive spending on the country's forthcoming football World Cup and Olympic Games.