Brazilian senators capped a session that lasted more than 20 hours early Thursday by voting to impeach the country's left-wing president, deepening political instability in Latin America's largest nation months before the Summer Olympics in Rio de Janeiro.

The 55-22 vote means that Dilma Rousseff will be suspended from office for the duration of her Senate trial, which could last up to six months. She will be replaced by Vice President Michel Temer.

Rousseff is accused of using accounting tricks to hide large budget deficits. The result of the upcoming trial will determine whether Rousseff can serve out her second term, or whether her ally-turned-enemy, Temer, will remain in the top job through December 2018.

"Did anyone think that we would get to 2018 with a recovery under this government? Impossible," said Jose Serra, the opposition Social Democratic Party's failed presidential candidate in the 2010 race that brought Rousseff into power. "The impeachment is just the start of the reconstruction."

The result was a major victory for the pro-impeachment camp, which achieved a far greater majority than the minimum of 41 votes needed to suspend Rousseff. It sends a signal that she faces an uphill battle to return to power.

Rousseff's impeachment ends 13 years of rule by the Workers' Party, which is credited with lifting millions out of abject poverty but has been vilified for being at the wheel when billions were siphoned from the state oil company Petrobras.

Temer, a 75-year-old career politician from the centrist Democratic Movement Party, has promised to cut spending and privatize many sectors controlled by the state, while insisting he would expand popular social programs.

For weeks, he has been quietly putting together a new Cabinet in expectation of taking over, angering Rousseff supporters who accuse him of being in on a plot to oust her.

The rancourous Senate debate, which began Wednesday morning, went on through the day and into the wee hours of Thursday.

During the debate, Humberto Costa, the Workers' Party leader in the Senate, brandished a photo of Rousseff from her days as a young Marxist guerrilla during the country's 1964-1985 dictatorship. The image showed her at the military proceedings against her.

Costa called the impeachment the second unjust trial Rousseff had endured, and charged Brazil's traditional ruling classes with attempting to reassert their power over the country and roll back Workers' Party policies in favor of the poor.

"The Brazilian elite, the ruling class, which keeps treating this county as if it was their hereditary dominion, does not appreciate democracy," Costa said.

At one point, Senate President Renan Calheiros told the legislators, "I'm asking for everybody's patience because we need to see this through to the end."

When the impeachment measure was introduced last year in Congress, it was generally viewed as a long shot: as late as February, consultancies like Eurasia were predicting it wouldn't even make it out of committee in the lower Chamber of Deputies.

But momentum built over several months, as Brazilians seethed over numerous corruption scandals linked to Petrobras and daily announcements of job losses added to growing desperation. The economy is expected to contract nearly 4 percent after an equally dismal 2015 and inflation and unemployment are hovering around 10 percent, underscoring a sharp decline since the South American giant enjoyed stellar growth for more than a decade.

The Senate action came after the lower house voted 367-137 last month in favor of impeachment.

Polls have said a majority of Brazilians supported impeaching Rousseff, though they also suggest the public is wary about those in the line of succession to take her place.

Temer has been implicated in the Petrobras corruption scheme as has Calheiros, the Senate head who is now No. 2 in the line of succession. Former House Speaker Eduardo Cunha, who had been second in line, was suspended from office this month over allegations of obstruction of justice and corruption.

Rousseff has vehemently denied her administration's financial sleight of hand moves constituted a crime and argued that such maneuvers were used by prior presidents without repercussions. She has stressed that unlike many of those who have pushed for impeachment, she does not face any allegations of personal corruption.

The Associated Press contributed to this report.