On Thursday, a Supreme Court justice, Teori Zavascki, ruled against Mr. Temer’s powerful ally, Mr. Cunha. As the speaker of the lower house of Congress who oversaw the vote in April to impeach Ms. Rousseff in the Chamber of Deputies, Mr. Cunha had adroitly fended off charges of taking as much as $40 million in bribes.

Scholars and political analysts described the initial ruling by Justice Zavascki, which the 11-member court later endorsed, as reflecting the capacity for Brazil’s legal system to curb abuses of power. Joaquim Barbosa, a former chief justice of the Supreme Court, called the move “extraordinary and courageous.”

The ruling to remove Mr. Cunha, an evangelical Christian radio commentator, sidelines a top political opponent of Ms. Rousseff after much of his role in impeachment process had been completed. The impeachment decision is now in the hands of the Senate, which is expected to vote against the president on May 11.

Mr. Cunha can appeal the ruling against him, and he is expected to do so. A spokesman for Mr. Temer said he would not appeal his conviction and would pay a fine of about $23,000. (Mr. Temer, 75, has already signaled that if he were to become president, he would not run for re-election.)