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.
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.
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.
Despite anger at rising unemployment, Rousseff's Workers Party can rely on strong support among millions of working-class Brazilians, who credit its welfare programs with pulling their families out of poverty during the past decade.
"The fight is going to continue now in the streets and in the federal Senate," said Jose Guimaraes, the leader of the Workers' Party in the lower house. "We lost because the coup-mongers were stronger."
Opinion polls suggest more than 60 percent of Brazilians support impeaching Rousseff, Brazil's first female president.
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.
Hundreds of thousands of demonstrators from both sides took to the streets of towns and cities across the vast nation. 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.
As the vote came to an end, hundreds of Rousseff supporters sat downcast on red flags and banners on the grass. A young couple, on the verge of tears, hugged each other.
On the pro-impeachment side of the wall, protesters sang and danced, drinking beer and munching popcorn. Some took selfies and performed handstands, celebrating a decision that many said was a victory against corruption.
"Impeachment sends a clear message that the politics of this country needs to be cleaned up," said Alesandra Dantas, a 28-year-old social worker.
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.
Critics of the impeachment process say it has become a referendum on Rousseff's popularity - currently languishing in single digits - which sets a worrying precedent for ousting unpopular leaders in the future.
They note that Rousseff is accused of a budgetary slight of hand commonly employed by many elected officials in Brazil.
With Brazilians transfixed by the congressional vote, broadcast live on television, legislators denounced corruption and the economic downturn as they voted against Rousseff. But few of them mentioned the budgetary allegations.
However, business lobbies have thrown their weight behind the ouster of Rousseff, as they look to Temer to restore business confidence and growth to the world's ninth largest economy.
Once regarded as an emerging markets powerhouse, Brazil has been hit by the end of a long commodities boom and lost its coveted investment grade credit rating in December.
Brazil's stocks and currency have been among the world's best-performing assets in recent weeks on growing bets that Rousseff would be removed from office, allowing Temer to adopt more market-friendly policies.
In a sign that rally could continue, an exchange-traded fund of Brazilian equities (1325.T) gained 3.8 percent shortly after the result was announced.
While Rousseff herself has not been personally charged with corruption, many of the lawmakers who decided her fate on Sunday have been.
Congresso em Foco, a prominent watchdog group in Brasilia, said more than 300 of the legislators who voted - well over half the chamber - are under investigation for corruption, fraud or electoral crimes.
As they cast their vote, some lawmakers said the next politician to be impeached should be the man leading the proceedings, Speaker Eduardo Cunha. He is charged with corruption and money laundering in the kickback scandal involving Petrobras, and he also faces an ethics inquiry over undeclared Swiss bank accounts.
"God have pity on this nation," Cunha said as he cast his vote in favor of impeaching Rousseff.