Venezuelan opposition figure Juan Guaidó was denied entry to the National Assembly to be re-elected as its head.
Dissident opposition politician Luis Parra, Mr Guaidó's rival, then declared himself parliament's new Speaker by megaphone - a move denounced by the opposition as a "parliamentary coup".
The opposition also said Mr Parra was sworn in without votes or quorum.
In a heated exchange at the doors, Mr Guaidó reportedly told a security officer: "This is unprecedented!"
Images later showed him and other politicians who support him trying to climb a fence to gain entry to the building.
Mr Guaidó said that only regime politicians and opposition deputies critical of him had been allowed to enter the National Assembly building, and that security forces had set up barricades in downtown Caracas.
Before the dramatic declaration, AFP reported that opposition deputy Jose Brito - another opponent of Mr Guaidó - told journalists that Mr Parra would stand for the role of Speaker.
"You could have been the future - now you are and will be the past," Mr Brito told reporters, addressing Mr Guaidó.
State broadcasters later described Mr Parra as the new Speaker.