SÃO PAULO—When Brazil’s celebrated corruption-fighting judge agreed to become President Jair Bolsonaro’s justice minister, he lent credibility to a leader who courted controversy. Eight months later, Sergio Moro is now himself the center of controversy.

Over the past month, The Intercept website in Brazil has published leaked text messages showing what it says is Mr. Moro, then working as a judge, secretly coordinating with prosecutors to convict former President Luiz Inácio Lula da Silva in 2017.

While Mr. Moro appears to be weathering the scandal, his critics say it threatens something more important than his career: the credibility of Brazil’s justice system and Car Wash, Latin America’s largest antigraft investigation.

“This has knock-on effects for the rest of the country,” said Felipe Cruz, head of Brazil’s Bar Association, which has called for Mr. Moro’s resignation. Due process is vital to the health of any democracy, he said. “Part of the public seems to think that the end justifies the means but this logic cannot be upheld by those in the justice system.”

While Brazil adheres to international guidelines that guarantee criminal defendants a fair trial and an impartial judge, the leaked messages appear to show Mr. Moro advising prosecutors on how to strengthen their case against Mr. da Silva, including passing on the contacts of a witness who could testify against him.