LIMA, Peru — A struggle between Peru’s president and congress over who will govern threatened to become a lengthy and destabilizing legal battle as each side dug in Tuesday amid the deepest constitutional crisis in nearly three decades, though one rival claimant to the presidency dropped out of the fight late in the day.

President Martín Vizcarra dissolved the opposition-controlled congress Monday and called new elections, saying the step was needed to uproot the nation’s endemic corruption. Defiant opposition lawmakers voted to suspend him from office and moved to replace him with one of Peru’s vice presidents who recently broke ranks.

But Mercedes Aráoz late Tuesday resigned the post proclaimed for her by lawmakers and urged Vizcarra to hold elections “in the shortest term.”

Earlier in the day, the military and governors stood by Vizcarra, while several private business coalitions said they would back Aráoz. There was no immediate comment from the two sides in the confrontation on Aráoz’s decision.

The 35-member Organization of American States urged Peru’s Constitutional Tribunal to weigh in on the feud as both sides accused the other of abusing power and jeopardizing the nation’s stability.

“It seems we are facing a protracted political crisis, with the dispute potentially ending up before courts,” said Maria Luisa Puig, an analyst for the Eurasia Group consultancy.

Peruvians appeared overwhelmingly in favor of Vizcarra’s decision, but the events nonetheless could threaten to fuel social unrest. Vizcarra is likely to continue governing as president while any challenge from the opposition works its way through court. He has already called for new legislative elections in early 2020.

But if congress should prevail, lawmakers would be entitled to stay in their posts until 2021, calling off Vizcarra’s elections and likely moving to impeach him, all acts that could irritate an already angry public with little to no faith in elected leaders.

Teresa Tintaya was among a handful of protesters outside congress Tuesday yelling phrases like, “Garbage congress, the people hate you!”

“President Vizcarra is a brave man,” she said.

Even before the turmoil, the nation was already on shaky political ground. Nearly every living former president has been ensnared in the mammoth Odebrecht corruption scandal, in which the Brazilian construction heavyweight admitted to funneling money to politicians around Latin America in exchange for handsome public works contracts.

Lower-ranking but still powerful judges, lawmakers and businessmen have been caught on wiretaps negotiating backroom deals, leading many Peruvians to conclude that no branch of their country’s turbulent government can be trusted.

Vizcarra rose to power last year after President Pedro Pablo Kuczynski resigned in relation to the Odebrecht probe and made defeating corruption his signature drive. He has succeeded where his predecessor failed in gaining the public’s support but repeatedly clashed with congress ruled by opposition leader Keiko Fujimori’s party.

Under Peru’s law, Vizcarra is entitled to dissolve congress if it rejects two votes of confidence in his administration. Whether or not two such votes have taken place is at the crux of the conflict between the executive and legislative branches.

Vizcarra contends a rejection vote during Kuczynski’s administration counts as the first because he is continuing his predecessor’s mandate. He argues that the second happened Monday when lawmakers proceeded with a vote to select new Constitutional Tribunal magistrates, defying his warning that he would interpret it as a vote against confidence.

Almost simultaneously, opposition lawmakers rushed to approve a vote of confidence that they say in effect inhibits Vizcarra from closing congress.

Pedro Olaechea, president of the dissolved legislature, said Tuesday that he and others believe the president’s act was a “new sort of coup.” He said lawmakers are deciding how to proceed but that what is likely to follow will be a “lengthy, tedious and delicate legal matter.”

“The event we are living will generate much uncertainty,” he said.

The OAS, in its statement, said the Constitutional Tribunal, the same institution at the center of the feud, should decide on the legality of Vizcarra’s action, but the regional body also characterized the call for new elections as a “constructive step.”

“It’s appropriate for the political polarization the country is suffering from be resolved by the people at the polls,” the organization said.

The Constitutional Tribunal is expected to decide several important cases in the months ahead, including a habeas corpus request to free Fujimori, who is being held as prosecutors investigate her for allegedly laundering money from Odebrecht.

Though the terms for all six magistrates had expired, Vizcarra, legal observers and human rights groups criticized the congressional action for its speed and lack of transparency. The newspaper El Comercio reported Monday that six of the candidates up for consideration are facing potential criminal or civil charges for offenses including kidnapping, extortion and sex abuse.

By law, congress is responsible for appointing the new judges, a stipulation that Vizcarra contends fuels political conflict.

The one magistrate selected by lawmakers Monday before congress suspended voting is a relative of the head of the legislature. It is still unclear whether the newly appointed judge might take his seat and if so who he would replace and how that might change the balance of the tribunal.

Rigoberto Cueva, who was demonstrating in favor of Vizcarra on Tuesday, said that whatever happens in court, it is clear what the public is clamoring for.

“It’s not Vizcarra who has won here, it’s the people,” he said. “And the people have been demanding that congress be closed.”