Brazilian President Dilma Rousseff lost a crucial impeachment vote in the lower house of Congress on Sunday and appeared almost certain to be forced from office in a move that would end 13 years of leftist Workers' Party rule.

As thousands of pro- and anti-impeachment protesters demonstrated outside Congress, the opposition comfortably surpassed the two-thirds majority needed to send Rousseff for trial in the Senate on charges of manipulating budget accounts.

Protesters hold a banner reading 'Dilma out', ahead of Brazilian President Dilma Rousseff's impeachment vote, in Brasilia, Brazil April 17, 2016 | Reuters

The floor of the lower house was a sea of Brazilian flags and pumping fists as dozens of lawmakers carried the deputy who cast the decisive 342nd vote in their arms.

In Brazil's largest cities of Sao Paulo and Rio de Janeiro, fireworks lit up the night sky and cars honked their horns in celebration after the vote.

If the Senate now votes by a simple majority to proceed with the impeachment as expected in early May, Rousseff would be suspended from her post and be replaced by Vice President Michel Temer as acting president pending her trial. Temer would serve out Rousseff's term until 2018 if she is found guilty.

People walk in front of a sign that reads: 'Impeachment' in Copacabana beach in Rio de Janeiro, Brazil April 17, 2016 | Reuters

The impeachment battle, waged during Brazil's worst recession since the 1930s, has divided the country of 200 million people more deeply than at any time since the end of its military dictatorship in 1985.

It has also sparked a bitter battle between the 68-year-old Rousseff and Temer, 75, that appears likely to destabilize any future government and plunge Brazil into months of uncertainty.

Opinion polls suggest more than 60 percent of Brazilians support impeaching Rousseff, Brazil's first female president.

People protest against Brazilian President Dilma Rousseff's impeachment in Rio de Janeiro, Brazil April 17, 2016 | Reuters

While she has not been accused of corruption, Rousseff's government has been tainted by a vast graft scandal at state oil company Petrobras and by the economic recession.

Millions watched the congressional vote live on television in bars and restaurants, in their homes or on giant screens in the street, like they would for a big soccer match.

The impeachment battle has paralyzed the activity of government in Brasilia, just four months before the country is due to host the Olympics in Rio de Janeiro, and as it seeks to battle an epidemic of the Zika virus, which has been linked to birth defects in newborns.

(Feature image source: Reuters)