BRASÍLIA — Brazilians booed him as he presided over the opening of the Olympics in Rio. He has been accused of taking bribes. The economy he is supposed to rescue is on the cusp of a depression.

Michel Temer, Brazil’s new president, may have just vanquished his rival, Dilma Rousseff, in the bruising impeachment battle that resulted in her final removal from office on Wednesday.

But for Mr. Temer, the hard part is just beginning.

“Get yourselves into the trenches,” urged Roberto Requião, a senator from Mr. Temer’s party who rebelled by siding with Ms. Rousseff in the impeachment vote. “Conflict will be inevitable,” he added, warning that Ms. Rousseff’s ouster had cleared the way for an era of intense division in Brazilian society.

The biggest challenge facing Mr. Temer, who largely operated in the shadows as Ms. Rousseff’s vice president before breaking with her earlier this year, is evident: the economy.