Venezuela's socialist government has installed a new head of Congress after armed troops blocked opposition legislators from entering parliament, in a move condemned by dozens of nations as an assault on democracy.

Troops with riot shields blocked opposition leader Juan Guaido from entering parliament for what was expected to be his re-election as head of Congress, at one point pulling him off the compound's iron railings after he tried to push past security forces.

The blockade allowed the ruling Socialist Party to hand the post to legislator Luis Parra, who was recently expelled by an opposition party over corruption allegations.

The gambit by the government of President Nicolas Maduro was slammed by the United States, the European Union and a dozen Latin American nations.

Opposition legislators quickly re-elected Mr Guaido - who is recognised by dozens of nations as Venezuela's rightful leader - in a session at the headquarters of a pro-opposition newspaper.

But the move may further weaken the opposition's already flagging campaign to oust Mr Maduro, and creates two competing leaders of parliament in a nation caught in a political standoff and suffering a hyperinflationary economic collapse.

"Today the dictatorship has committed another blunder," Mr Guaido said after taking the oath of office at the offices of El Nacional newspaper. "Today we once again soundly defeated the plans of the dictatorship."

The opposition's tally showed 100 of parliament's 167 legislators voted in his favor.

Mr Guaido last year led a groundswell movement to push Mr Maduro from power, denouncing his 2018 re-election as a fraud and assuming a parallel presidency that quickly won the recognition of most Western and Latin American nations.

But Mr Maduro has clung to power, thanks to continued support from the military and the backing of China, Cuba and Russia. He has denounced Mr Guaido as a US puppet.