With a fiesta of football inside and demonstrations outside, Sunday was a day of stark contrasts in Rio as hosts Brazil whipped Spain 3-0 to win a third successive Confederations Cup even as protesters clashed with police near legendary Maracana stadium.
Inside the arena, the atmosphere was deafening as an inspired Brazil raced to a two-goal lead by half-time through Fred and Neymar before Fred added a third.
The contest was all but over as Sergio Ramos then missed a penalty for Spain, the world champions.
The hosts' victory thrilled the partisan crowd of 78,000, most of whom wore the Selecao's green and yellow jersey.
And it lifted the spirit of a nation reeling from more than two weeks of social turmoil, reflecting public anger over inadequate public services and the high cost of hosting the Confederations Cup and next year's World Cup.
President Dilma Rousseff, who did not attend the match, sent a message of congratulations to the national squad for its fourth Confederations Cup win.
"In this memorable campaign, our athletes showed joy, creativity, team spirit and unity which conquered all Brazilians and they offered the world a great spectacle. Today I joined all Brazilians in celebrating this great victory," said Rousseff, whose popularity has plunged since the start of the unrest.
Two weeks ago, she and FIFA President Sepp Blatter were booed by demonstrators at the opening game of the tournament in Brasilia.
Earlier Sunday, thousands of demonstrators marched toward Maracana, most of them peacefully.
"There won't be a final," chanted some of them, who earlier released 20 balloons into the sky with a huge poster reading "FIFA, get out."
But a small group of hooded protesters, some armed with screwdrivers and slingshots, lit a fire in the street and hurled stones at police who responded by firing tear gas and rubber bullets as police helicopters circled overhead.
The demonstrators ran in all directions under a cloud of tear gas but police awaited them at every corner.
"Unfortunately, the incidents were started by protesters who hurled makeshift bombs and stones at police," Henrique Guelber of the Center for the Defense of Human Rights, told the G1 news website.
The demonstrators 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.
"Stop the genocide of Indians" or "political asylum for (WikiLeaks chief Julian) Assange," read some of their placards held by the demonstrators.
Many 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 and vandalism.
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.
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.