Brazilian President Michel Temer speaks at a ceremony at the Planalto Presidential Palace, in Brasilia on Aug. 1. (Eraldo Peres/Associated Press)

The lower house of Brazil’s Congress voted Wednesday to block a corruption trial against Michel Temer, a victory for the embattled president that occurred 15 months after his predecessor was suspended for financial irregularities.

Temer’s opponents fell well short of the two-thirds majority required in the Chamber of Deputies to send him to trial in the Supreme Court. In the end, 263 lawmakers voted for the president, 228 voted against him and the remaining 22 didn’t vote or abstained.

The president was determined to remain in power and aggressively courted legislators’ support well into the session, which stretched over more than 11 hours Wednesday.

With more than 80 percent of Brazilians in favor of sending the president to trial, according to polls, the chamber’s decision was a testament to the president’s skillful maneuvering, and spoke to the desire for greater political and economic stability in Brazil.

Temer, the first sitting Brazilian president charged with corruption, is accused of receiving $150,000 from a wealthy meatpacking executive — part of a $12 million bribe he allegedly accepted through an aide. Temer denies the accusations and has rejected calls for his resignation.

The vote came as Brazilian politics are in turmoil. Last month, Luiz Inácio Lula da Silva, who led Brazil from 2003 to 2010, was convicted of corruption and money laundering and sentenced to more than nine years in prison. He has appealed the verdict.

Temer’s predecessor, Dilma Rousseff, was suspended in May 2016 on charges of budget mismanagement, and she was removed from the presidency three months later.

As Wednesday’s session began, dozens of representatives gathered in the center of the chamber, chanting: “Out Temer. The people want to vote. Direct elections now.”

In speeches ahead of the vote, Temer’s supporters focused on the importance of political stability for the country’s economy.

“Brazil cannot return to chaos. That’s why I’m voting against this charge,” said representative Hidekazu Takayama of the allied Socialist Christian Party.

“The president chose to confront the crisis by delivering bitter but necessary medicine,” said representative Paulo Abi-Ackel of the coalition Brazilian Social Democracy Party. “Is now the right time to remove the president of the republic? We need to continue these efforts to reestablish confidence in the future of the country.”

A member of Brazil's Homeless Workers Movement shouts during a protest against President Michel Temer in Sao Paulo, Brazil, on Aug. 2.

But in Sao Paulo, hundreds of protesters opposing Temer, whose approval ratings sank to 5 percent ahead of the vote, lit tires on fire to block access to major highways.

While more than 80 percent of Brazilians believe that Temer should stand trial, according to a recent poll, he maintains a significant base in Congress. He was expected to gather about 260 votes in his favor, putting him safely above the 172 needed to evade trial, according to an analysis by political consultancy firm Arko in Brasilia, the capital.

But hours before the vote, the Social Democracy Party, Temer’s largest coalition party, instructed supporters to vote in favor of the charges.

In May, leaked recordings appeared to show the president condoning the payment of hush money to protect Joesley Batista, a meatpacking executive who was under investigation for corruption. A few weeks later, video emerged of a close aide exiting a pizza parlor with $150,000 in cash, allegedly intended for Temer.

The revelations sent shock waves through Brasilia, which already was reeling from Operation Car Wash, a corruption investigation that has shredded Brazil’s political elite but had not previously tarred Temer.

The president has been determined to remain in power and has dismissed some ministers to allow them to cast ballots as legislators in his defense. The night before the vote, Temer attended a dinner with more than 100 lawmakers at the home of the vice president of the lower chamber. Temer was greeted with applause and urged the legislators to help him usher in a new era in Brazilian politics.

Temer’s government pumped $25 million in federal funding into legislators’ pet projects after the accusations arose in May. Over the past two months, the president has rewarded allied parties with prominent positions within his cabinet and fired coalition members whose parties broke with him.

Temer is still expected to be formally charged in the next few months with racketeering and obstruction of justice in connection with the same case. The Chamber of Deputies also would have to approve those charges before a trial.

Although his supporters have been betting that the president can withstand these accusations long enough to complete the 18 months left in his mandate, the scandal has paralyzed Temer’s government and stalled flagship reform programs that he hoped would promote recovery from Brazil’s longest recession on record.

Temer has suffered from dismal approval ratings, with thousands of Brazilians questioning his right to rule.

“To pacify the country, we need direct elections. Temer does not have legitimacy,” opposition member Weliton Fernandes Prado said. “We vote for the acceptance of the charges and want direct elections.”