RIO DE JANEIRO — Brazil’s justice minister, Sergio Moro, a former federal judge who became the face of a powerful anti-corruption crackdown that swept Latin America, resigned Friday after accusing President Jair Bolsonaro of seeking to assert improper control of the federal police for political gain.

The resignation of Mr. Moro, one of Brazil’s most popular politicians, set off a political uproar in Brazil, as critics across the political spectrum accused the president of having undermined a key pillar of democracy.

In his resignation speech, Mr. Moro delivered an extraordinary parting rebuke, recounting in great detail a conversation during which he failed to persuade the president not to follow through on his plan to fire the federal police chief, Maurício Valeixo, who was forced to step down Friday morning.

Brazil’s attorney general, Augusto Aras, later on Friday asked the Supreme Court to open an investigation into the outgoing minister’s account.