Protesters clashed with police near Rio's iconic Maracana stadium Sunday, only minutes before th start of the Brazil-Spain final of the Confederations Cup, AFP correspondents reported.

The confrontation started when some of the demonstrators hurled stones at police who responded by firing tear gas, they added.

A few minutes later, the match got under way in a climax to the two-week Confederations Cup, a dry run for next year's World Cup.

Pandemonium broke out inside the hallowed arena when Brazil scored first and fast, with a goal by Fred.

Earlier, some 5,000 people, according to the organizers, sang and danced to samba music as they marched toward the stadium but were blocked a police security cordon.

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.