Thousands of Rio residents staged boisterous but peaceful protests Sunday near the venue for the Brazil-Spain final of the Confederations Cup, a dry run for next year's World Cup.
Some 5,000 people, according to the organizers, sang and danced to samba music as they marched toward Rio's Maracana stadium but were blocked a police security cordon, hours before the 7 p.m (2200 GMT) kickoff.
Police, who earlier estimated the crowd at 2,500, said the march was peaceful.
The marchers responded to calls on social media to turn out to back the national squad but also to protest the country's inadequate public services -- a key gripe at the core of two weeks of demonstrations that have rocked the South American giant.
More than 11,000 police and troops were mobilized to ensure security for 78,000 fans at the Maracana arena as the curtain falls on a tournament hit by the unprecedented social unrest, with more than 1.5 million Brazilians taking to the streets nationwide over the past two weeks.
"We are against the privatization of the stadium and forced housing displacement, linked to the 2014 World Cup and the (2016 Rio summer) Olympics," said Renato Cosentino, a spokesman for one of the groups sponsoring Saturday's protest.
Hundreds of demonstrators also rallied in the Tijuca district, about one mile from Maracana, dancing and chanting: "FIFA, pay my (bus) fare" or "Maracana is ours."
"I am here in an act of patriotism, for more education, health, transport -- and less football," said 69-year-old Nelson Couto, wearing the green and yellow colors of the Brazilian flag.
Police invited the country's Bar Association as well as federal and state prosecutors to monitor their security deployment following charges of police brutality during earlier protests.
Meanwhile, another 3,000 protesters, mostly youths, rallied on Saens Penha square, chanting "there won't be any final" as they made their way toward Maracana, AFP correspondents reported.
"Stop the genocide of Indians" or "political asylum for (WikiLeaks chief Julian) Assange," read some of their placards.
The marchers included indigenous people who were expelled from A "Maracana Village" they had set up on the on the site of the former Indian Museum located next to the stadium.
A small demonstration was also held in the northeastern city of Salvador outside the stadium where Italy took third place in the Confederations Cup Sunday after beating Uruguay 3-2 on penalties.
A small group of protesters also rallied outside a Salvador hotel housing a delegation from world's football governing body FIFA.
Meanwhile, fans gathered outside Maracana.
"We want peace, peace and football - not protests," Francisco da Assis , as he held a pole on which he had stuck a globe topped off with a model of a white dove.
Others danced the samba and hoisted a banner reading "a year to go to the World Cup. Time for a better reaction, better quality of life, less corruption, less taxes."
Inside the Maracana, dancers covered by football-patterned parasols gyrated in formation while samba crooner Arlindo Cruz sang the hit "Meu Lugar" (my place).
Fans screamed with delight as pictures flashed up on the big screen of their team arriving - having roundly jeered the Spanish when they entered the stadium.
Despite the festive atmosphere, many Brazilians are angry at the $15 billion being spent to host the tournament and next year's World Cup.
Protesters complain the government has found billions of dollars to build brand new stadiums for 12 World Cup host stadiums while transport, education and health remain underfunded.
Some of the demonstrations have been marred by sporadic violence, but the disparate groups calling for people to protest urged a peaceful march with no vandalism.
Leftist President Dilma Rousseff, whose popularity has plunged since the start of the unrest, will not attend the Spain-Brazil final.
Two weeks ago, she and FIFA President Sepp Blatter were booed by demonstrators at the opening game of the tournament in Brasilia.
The mass protests, which appear to tapering off this week, were the largest in Rio where they brought 300,000 people into the streets Sunday on June 20, when they degenerated into violence, looting and scenes of urban guerilla warfare.
Blatter was expected in Rio after attending the third place playoff encounter between Italy and Uruguay.
FIFA itself has been the target of the public ire, amid claims the organisation is masterminding a multi-billion dollar "circus" which only benefits itself.
FIFA insists it will reinvest the its revenues in football's grassroots.
Despite the social turmoil, which began in Sao Paulo in early June over the rising cost of public transport, polls show more than two-thirds of Brazilians support their country hosting the World Cup for the first time since 1950.
Brazil is the most successful country in World Cup history, with five wins.
In the Confederations Cup, the national squad is gunning for a third straight title and fourth overall, whereas Spain, the current World Cup champions, have yet to lift the trophy.
The finalists have only met on eight previous occasions: Brazil winning four to Spain's two with two matches drawn.
But if history favors the South Americans, Spain have not lost a competitive match in 29 games, since their shock defeat to Switzerland at the start of the 2010 World Cup.