Demonstrators create a flaming barricade during an anti-government protest in Brasilia (Eraldo Peres/AP)

Brazil's president has ordered federal troops to restore order in the country's capital after some ministries were evacuated during clashes between police and protesters who are seeking the leader's removal.

Tens of thousands of demonstrators marched to congress to protest against economic reforms that President Michel Temer is pushing through and to demand he step down amid a corruption scandal.

What began as small scuffles between police and protesters who tried to jump a cordon mushroomed into a series of clashes in which officers fired tear gas and pepper spray to contain the crowd.

Protesters set fires and used portable toilets to create barricades.

As the clashes grew, some government agencies were evacuated, the president's office said.

The G1 news portal reported that protesters set a fire in the agriculture ministry.

In a brief national address during the unrest, defence minister Raul Jungmann said troops were being sent to guard federal buildings, including the presidential palace.

The deployment was authorised by a presidential decree that left open the possibility that soldiers could be used more widely in Brasilia.

The decree said Mr Jungmann would decide the scope.

"This mess, this mayhem is unacceptable," Mr Jungmann said.

"President Temer will not allow that."

Mr Jungmann added that troops had already entered the foreign ministry.

Images on television showed soldiers outside the presidential palace.

Mr Temer is struggling to retain power after the release of a recording that appears to capture him approving hush money for a convicted former politician.

Brazil's top court is investigating him for alleged obstruction of justice and involvement in passive corruption.

The president is resisting calls to resign and has said he will fight the accusations.

The move to use the military in the face of protests could heighten anger at the government and senior officials were already distancing themselves from the decision.

Rodrigo Maia, the speaker of the lower house of congress, said he had asked Mr Temer to instead use the National Force, an elite police entity.

Justice Marco Aurelio Mello, of Brazil's highest court, said he was "a little concerned about the context" of Mr Temer's decision.

Mr Temer's popularity was low even before the latest scandal broke, in part because of opposition to an economic overhaul that he wants to push through congress, including loosening work rules and changing the pension system.

Several of his allies and aides have also been caught up in a wide-ranging corruption investigation that has jailed business leaders and senior politicians.

Since the scandal broke, the pressure on Mr Temer has continued to ratchet up.

Federal police asked Mr Temer on Wednesday to submit to questioning, the president's defence team said in a statement, but his lawyers called the request inappropriate.

Mr Temer lost yet another aide when Sandro Mabel resigned on Wednesday and published a letter saying he needs to spend more time with his family.

He is the latest in a string of aides and allies who have resigned or been fired amid corruption allegations.

With Brazil deeply divided and a political crisis deepening, a session of the lower house of congress became chaotic, with opposition politicians surrounding the speaker's desk in protest and holding signs saying congress's workings should be transparent.

Several politicians have submitted requests for Mr Temer's impeachment to Mr Maia, the speaker, and he has angered them by saying he will take his time to review the requests.

"Right now there is only one option, and your excellency cannot run away from your responsibilities, the first thing that has to be done is to immediately form a commission to impeach Michel Temer," said politician Glauber Braga.

Mr Maia eventually called an end to the session.

While congress debated, 35,000 people were marching towards the chamber down a long avenue lined with the main government buildings, including the Supreme Court, the presidential palace and the ministries.

Protesters shouted "Out with Temer!" and carried signs calling for immediate direct presidential elections.

If Mr Temer resigned, the constitution says congress would elect the next president, who would hold power for the rest of his term, which runs to the end of 2018.

But many Brazilians, disgusted with the political class, want to vote themselves.

While the demonstration was initially peaceful, police and protesters began clashing as the protest neared congress.

Police in riot gear, some on foot holding shields and others on horseback, lined up near the chamber.

The violence began when protesters tried to break through a cordon, the security department said.

Protesters later began to disperse, but small clashes continued with police.

In Rio de Janeiro, a protest in front of the state legislature also became briefly chaotic.

"The state today is in a sea of debt because of corruption," said Julio Cesar Azevedo, a leader of a union that represents prison guards.

"It's not right that public servants are paying this bill."

The state of Rio is in serious financial trouble and many public servants have received their salaries late or not at all.

AP

PA Media