Thousands of Rio residents staged a boisterous but peaceful protest 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 emerging 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 (transport) fare" or "Maracana is ours."
Some distributed leaflets explaining what to do in cases of violence, such as not to run if police fire tear gas and not to wear contact lenses.
"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 march was scheduled in Rio later in the day and in the northeastern city of Salvador where Italy took third place in the Confederations Cup Sunday after beating Uruguay 3-2 on penalties, a small protest was held outside the arena.
The G1 news website said a small group of demonstrators 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.
"Brazil will win - the football, and socially - 2-1, 3-1, 4-2, it doesn't matter. The country will win," he shouted.
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."
Despite the festive morning cheer, many Brazilians are angry at the $15 billion being spent to host the tournament and next year's World Cup.
Protesters are complaining that 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 -- 300,000 marched in Rio 10 days ago -- have been marred by sporadic violence, but the disparate groups calling for people to protest here Sunday have called for 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 as they attended the opening game of the tournament in Brasilia.
A Datafolha poll said Rousseff'sapproval rating has plunged from 57 percent down to 30 percent since June 6-7.
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 in Salvador.
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.
Their most recent encounter was a 1999 friendly.
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.