Brazilian President Dilma Rousseff, caught in the middle of a corruption probe and impeachment proceedings in Congress, issues a statement against impeachment. (Reuters)

Brazil is on the verge of a historic impeachment vote in its National Congress that could oust Dilma Rousseff, the president of South America’s most populous country.

If two-thirds of lawmakers in the lower house opt for an impeachment trial in a vote that starts at 1 p.m. on Sunday, and the upper house later endorses the decision by a majority, the leader of the world’s fourth-biggest democracy will be suspended for 180 days and replaced by her vice president, Michel Temer.

A trial in the Federal Senate — which could happen while Rio de Janeiro stages South America’s first Olympics in August — would follow. But by then, Rousseff’s presidency may well be over.

The country is looking nervously over the brink, divided over its future and the very legality of the process that Rousseff and her supporters say is an institutional coup and an attack on Brazil’s young democracy.

Brazil’s two-decade military dictatorship ended in 1985, and it has already impeached one president — Fernando Collor de Mello in 1992 — since then. But Collor’s impeachment, on corruption grounds, was widely supported, and Brazil is split over Rousseff’s fate.

Pro- and anti-impeachment protesters are camped out in Brasilia, and a metal barrier has been erected outside Congress to keep them apart. Inside, politicians are fighting a last-minute battle to persuade a dwindling group of deputies yet to make up their minds.

On Friday afternoon, the pro-impeachment camp said it had enough votes to win. Hours later, the government had turned some deputies back in its favor and was claiming it could survive.

“Let’s add up the no’s, the abstentions and the absences,” said Afonso Florence, leader of the Workers’ Party caucus in the lower house.

Rousseff, who was narrowly reelected in 2014, is accused of breaking a responsibility law in using state bank funds and accounting trickery to cover gaps in her budget. She denies the allegations.

Hanging over the process is an enormous corruption scandal involving billions of dollars in bribes and kickbacks at state-run oil company, Petrobras, which has entangled lawmakers and officials from her own Workers’ Party and its coalition allies. Last month, her predecessor, Luiz Inácio Lula da Silva, was taken in for questioning in connection with the case.

Politically, if not legally, this is as much a part of the impeachment process as the accusations over fiscal irregularities.

The scandal has prompted street protests across Brazil over the past year calling for Rousseff and Lula to be jailed. In polls, a majority of Brazilians support her ouster.

To confound her problems, Brazil is swamped by its worst economic recession in decades. In Congress, key parties in Rousseff’s ruling coalition have progressively abandoned ship.

Temer, who Rousseff accuses of conspiring against her, has been holding talks with queues of politicians at his official residence, the Jaburu Palace. Pro-impeachment deputy Levy Fidelix said there were about 40 lawmakers waiting when he jumped the queue there last Wednesday. Lula has also been hosting negotiations with lawmakers in a luxury hotel near Congress. “It’s a war of up and down. It’s like the stock exchange,” he told supporters during a speech in Brasilia on Saturday.

Lelo Coimbra, a federal deputy for the Brazilian Democratic Movement Party, or PMDB, said he will vote for impeachment. “You have a government that cannot perform its functions,” he said. “A paralyzed government.”

Until last month, his party was Rousseff’s biggest ally in Congress. Now most of its deputies will vote for impeachment. But a few will vote against — such as Health Minister Marcelo Castro, who stood down last week in the midst of Brazil’s Zika epidemic so that he could cast his vote as a federal deputy.

Rousseff’s supporters question the legal basis for her impeachment and say those orchestrating the vote, such as lower house speaker Eduardo Cunha, are guilty of corruption and that Rousseff is innocent. Cunha has been charged by Brazil’s Supreme Court for his involvement in the Petrobras scandal, and Rousseff has not.

“It is not just unconstitutional. It is not just illegal. It is immoral,” said Jean Wyllys, a federal deputy for the small Socialism and Freedom Party. Across Brazil, actors, feminists, university students, rural workers’ groups and trade unions have staged events protesting impeachment.

“I did not commit a crime of responsibility. There is no charge of corruption or diverting public money against me,” Rousseff said in a video speech released Friday on the Internet.

Her opponents counter that she was chair of the Petrobras board and head of the Mines and Energy Ministry while much of the corruption was going on. A former government senator has accused her of attempting to interfere in the investigations.

Legal experts are divided as to whether the fiscal maneuvers she is accused of, also utilized by previous presidents such as Lula and Fernando Cardoso, justify impeachment. Brazil’s Federal Court of Accounts used them to reject Rousseff’s government’s 2014 accounts.

“This was never considered illegal,” said Camilo Zufelato, a professor of procedural law at the University of Sao Paulo’s law faculty in Ribeirao Preto.

“I don’t see why that means that she should be acquitted. At some point we are going to have to start taking the law seriously,” said Ivar Hartmann, a law professor at the Getulio Vargas Foundation’s law school in Rio de Janeiro.

Even some who had voted for the Workers’ Party said they believed it — and all parties in Brazil — was corrupt. “These are things that everyone did,” said Sao Paulo bus driver Veronica Gusmão, 26. She would still vote for Lula if he ran in the 2018 election, she said.

In a sign of the divide that has split Brazil, her boyfriend, Cherlys Meira, 43, also a bus driver, said he would not.

“The politicians are all focused on this business of impeachment and forgot the rest of the country,” he said.