CARACAS, Venezuela — The government of President Nicolás Maduro attempted a de facto takeover of Venezuela's legislature on Sunday, swearing in its own candidate as head of the National Assembly in a move apparently orchestrated to rob international credibility from Juan Guaidó, who had led the body and has staked a rival claim as head of state.

The dramatic events marked a sharp escalation in Maduro’s gambit to end Guaidó’s quest to unseat him and sparked immediate condemnation by Washington, which has strongly backed the 36-year-old opposition leader. Opposition officials declared the move an effective “parliamentary coup” meant to consolidate Maduro’s near-dictatorial powers.

“Today, they dismantled the rule of law, assassinating the republic, with the complicity of a group of traitor lawmakers,” Guaidó told reporters outside the parliamentary building.

Later Sunday, Guaidó sought to counter the move by gathering opposition lawmakers at the headquarters of El Nacional, a local newspaper, to cast an official vote. In a 100-to-0 tally — enough to put him over the top in a full session of the 167-seat chamber — those present reelected Guaidó as head of the legislature. Twenty-eight of the 100 were votes from stand-ins of exiled lawmakers.

But Maduro, in an address to the nation, hailed what he called the National Assembly’s “new leadership.”

“A very corrupt person leaves the presidency of the National Assembly today, as a millionaire, a billionaire,” said Maduro, referring to Guaidó. He added, “to justify their defeat, they say that a security operation was launched” to stop them.

The attempt to replace Guaidó — who declared himself interim president a year ago and promised to oust Maduro for claiming reelection in a tainted 2018 vote — appeared to be a carefully organized plan many weeks in the making.

Opposition officials have warned since last month that Maduro’s government was handing out suitcases of cash to woo lawmakers. But they thought they had successfully countered the operation, and on Sunday, Guaidó began the day anticipating his reelection as head of the National Assembly, viewed internationally as the last democratic institution in the authoritarian South American state. Guaidó’s claim as the nation’s true president — recognized by nearly 60 countries, including the United States — has been based on his status as the assembly’s chief.

But security forces loyal to Maduro formed a cordon early Sunday around the assembly building in central Caracas, blocking some opposition lawmakers from entering. Lawmakers who back Maduro — including several allegedly involved in a government plot to buy votes — were allowed to pass. At one point, Guaidó sought to scale the spiked wrought-iron fence surrounding the assembly and force his way in, according to a video issued by the opposition.

At the same time, Luis Parra — a former opposition politician who was one of several lawmakers accused last month of accepting government bribes — announced his surprise candidacy against Guaidó via Twitter on Sunday morning. Hours later, his swearing-in was shown on state television.

Parra is thought to have had the support of at least 40 lawmakers from Maduro’s party and an unknown number of others who the opposition claims have been bribed. But there was no evidence that an actual vote had taken place. The opposition also insisted that there had been no legal quorum because Guaidó, the chamber’s leader, had not been present to validate the session.

Sedition within the opposition, however, appeared to run deeper than some had feared. For instance, Luis Stefanelli, an opposition lawmaker who fled the country after claiming to reject a government bribe, had appointed a “loyal” stand-in to vote in favor of Guaidó on Sunday. But he said in a tweet that his stand-in had “betrayed him” and had instead stood with the government’s pick, Parra.

The government’s action appeared designed to complicate Guaidó’s international recognition and provide some nations that might be considering pulling their support for him additional legal cover to do so.

But the move also creates new logistical and technical hurdles for an already beleaguered opposition, including how and where to continue meeting and passing legislation.

Guaidó’s strongest backers — particularly in Washington — disregarded Sunday’s maneuvers in the National Assembly as dictatorial theatrics. The move comes as the United States — which has slapped tough sanctions on Maduro’s government, including an oil embargo — is weighing more confrontational steps, such as a possible naval blockade of Venezuelan oil being shipped to Cuba, the Maduro government’s chief regional ally.

In a statement, Secretary of State Mike Pompeo congratulated Guaidó on his “re-election” and condemned the “failed efforts” by Maduro to “negate the will of the democratically elected National Assembly.”

He charged Maduro’s government with seeking to “forcibly” deny access to Guaidó and other lawmakers after realizing its campaign of “bribery and intimidation” had failed to secure enough votes to oust him.

“Juan Guaido personifies the Venezuelan people’s struggle to reclaim the prosperity and democracy they once enjoyed,” Pompeo said in the statement. “No regime thugs, no jail cells, and no bribery or intimidation can subvert the will of the Venezuelan people.”

Few immediately saw Maduro as gaining international support from the move. A host of nations, including Brazil, Canada and Chile, quickly rejected Sunday’s attempt to install Parra. In a statement, the European Union said Sunday’s “serious irregularities” constituted “a new step in the deterioration of the Venezuelan crisis. As a consequence, the E.U. continues to recognize Juan Guaidó as the legitimate President of the National Assembly until the conditions for a proper voting session can be assured.”

The Maduro government has made attempts to declaw the National Assembly since the opposition won a sweeping majority in 2015. In 2016, the pro-Maduro Supreme Court officially stripped it of its legislative authority. A year later, the court announced it would dissolve the institution, a threat it never followed through on after the ruling generated internal controversy and street protests. In 2017, Maduro’s government created a “Constituent Assembly,” made up exclusively of its own backers, which sought to supplant the National Assembly’s authority.

But the opposition has managed to keep the institution at the center of its fight to oust Maduro, holding sessions weekly and using it as a legal backup to Guaidó’s claim to the presidency. It has given Guaidó constitutional legitimacy in the eyes of foreign powers, based on the fact that he and his supporters were elected by a majority in 2015 — the last time a vote here was seen as generally democratic.

The government’s bold move on Sunday comes at a dangerous time for the opposition. After a year in which many Venezuelans believe he overpromised how quickly Maduro could be forced from office, Guaidó has seen his popularity sharply slip. Attempts to turn the nation’s top military brass against Maduro have failed, and the opposition is reeling from accusations of turncoats and festering corruption within its own ranks.

Last month, Parra was ejected from one of the main opposition parties, Primero Justicia, after being accused of accepting bribes in exchange for lobbying on behalf of pro-Maduro business executives. Opposition officials also claim that he is one of several lawmakers who have accepted bribes to abandon Guaidó — an allegation Parra has denied even as he has begun to openly criticize Guaidó.

Guaidó’s team, in anticipation of victory on Sunday, had drafted plans to “relaunch” his presidency — including increasing the pressure on Maduro and spearheading more and better distribution of medicine and food in a nation brought to its knees by one of the world’s worst economic collapse’s in recent history.

“This is the equivalent of a coup against an institution that was legitimately elected,” said Luis Vicente León, director of the Caracas-based Datanalisis polling agency. “We only add one more illegitimate institution to the game that will not be recognized by the opposition’s international allies.”

“But,” he added, “for an opposition that had already been weakened, this is not good news. It loses operational capacity and becomes more dependent on an international community that doesn’t have much more maneuvering power left.”

Faiola reported from Miami. Mariana Zuñiga in Caracas contributed to this report.