Brazilian legislators have voted in favour of impeaching President Dilma Rousseff after a contest that has deeply divided the country and could end more than a decade of left-wing rule.
Tens of thousands of pro and anti-impeachment protesters gathered in the capital Brasilia and other cities to watch the dramatic vote, which was shown live on national television on Sunday.
The impeachment motion will now go to the Senate which will vote, probably in May, on whether to open a trial.
WATCH: Dilma Rousseff talks to Al Jazeera
If the Senate votes by a simple majority to go ahead with the impeachment, Rousseff, 68, would be suspended from her post and be replaced by Vice President Michel Temer as acting president, pending a trial. Temer would serve out Rousseff's term until 2018 if she were found guilty.
The impeachment battle, which comes 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.
The 513 legislators voted one by one, all of them given 30 seconds to speak before casting their ballots. The floor of the lower house was a sea of Brazilian flags and pumping fists as dozens of MPs carried the deputy who cast the decisive 342nd vote - needed for impeachment to succeed - in their arms.
During the deliberations leading up to Sunday's crucial vote, one opposition deputy after the other ignored the formal charges against the president to justify their call for impeachment.
Instead, they insisted Rousseff had to go because she had destroyed Brazil's buoyant economy and sunk it into deep recession and double-digit inflation.
Outside Congress, rival protest rallies were separated by a metal barrier. Rousseff supporters cried while her opponents cheered every "yes" vote.
READ MORE: Dilma Rousseff caught in media firestorm
The ruling Workers' Party vowed to continue to fight to keep Rousseff in the presidential palace.
"The fight is going to continue now in the streets and in the federal Senate," said Jose Guimaraes, the leader of the party in the lower house. "We lost because the coup-mongers were stronger."
Rousseff is accused of making illegal accounting moves to mask government shortfalls during her 2014 re-election, but she has not been accused of corruption.
Many Brazilians also hold her responsible for the failing economy and a corruption scandal centred on state oil company Petrobras - a perception that has left her government with 10 percent approval ratings.
Rousseff accused Vice President Temer and the house speaker of "treachery" and plotting what she has consistently called a coup.
She also pledged to "fight until the last minute ... to foil this coup attempt".
Despite anger at rising unemployment, Rousseff's Workers' Party can rely on strong support among millions of working-class Brazilians, who credit its welfare programmes with pulling their families out of poverty during its 13 years in power.
|Rousseff is accused of trying to cover up government shortfalls during her 2014 re-election [Eraldo Peres/AP]
Source: Al Jazeera and agencies