BRASILIA, Brazil — Brazil's embattled president survived a key congressional vote that could have suspended him over a bribery charge, mustering enough support late Wednesday to stay in office and avoid being tried by the country's highest court.

President Michel Temer needed the support of just one-third of the 513 members of the lower Chamber of Deputies, or 171 members. Hours after the voting began, he had received the number of votes he needed. A final tally was expected later.

While Temer was clearly victorious, he won't likely have much time to celebrate. Attorney General Rodrigo Janot, who leveled the bribery charge against Temer, is expected to charge him with obstruction of justice by the end of the month. That would provoke a second vote, forcing his allies to once again decide whether to risk their own political futures by sticking with the deeply unpopular leader. All 513 seats in the chamber are up for election next year.

The bribery allegation, which stunned even Brazilians inured to graft cases, was the latest in a bevy of scandals that has rocked the administration and created deep uncertainty and angst in Latin America's largest nation.

The vote in the Chamber of Deputies began after a day of hearings and vote cajoling by both sides behind the scene. Opposition lawmakers tried unsuccessfully to delay the vote, an acknowledgement that they likely wouldn't get enough support to suspend Temer despite his dismal support nationwide. The latest national poll said just 5 percent of Brazilians approval of Temer.

Throughout the day, there was shouting and even periodic pushing between lawmakers.

"Temer is a crook and he needs to sort out his situation with the Justice Department," said Elvino Bohn Gass, a member of the Workers' Party, one of the main opposition parties. "Brazil should not be governed by a gang of thugs."

For the vote, which was telecast by the influential Globo network, each member was announced and asked his or her vote. While members voting against Temer were outspoken, most of those who supported him cast their vote without speaking, a sign that many preferred not to broadcast their support for the deeply unpopular leader.

"Brazil can't change presidents three times in one year," said Sergio Moraes, a Temer supporter. "He will be investigated later."

Temer, then vice president, took office about a year ago after Dilma Rousseff was impeached and removed as president for improperly handling government finances.

Since taking power, Temer's administration has been rocked by repeated scandals while still managing to move unpopular legislation forward, such as a loosening of labor rules and proposals to trim pension benefits.

The ambitious economic overhaul agenda, supported by Brazil's business class, has helped the 76-year-old Temer stay in office so far despite the uproar over corruption allegations.