RIO DE JANEIRO — The federal judge who doomed former President Luiz Inácio Lula da Silva’s bid to return to power by convicting him on corruption charges last year, agreed on Thursday to take a cabinet post in the government of the country’s new president, Jair Bolsonaro.The decision by the judge, Sérgio Moro, to take the helm of the Justice Ministry was met with both outrage and jubilation, a reflection of how polarizing he has become.The position is newly reconfigured to oversee efforts to fight organized crime and corruption. Mr. Moro, the most visible law enforcement figure in a sweeping corruption inquiry that began in 2014, has been hailed at home and abroad as a crusading disrupter of a political class many saw as descending into kleptocracy.Yet some Brazilians also came to regard him as a political operator doing the bidding of conservative politicians, particularly as he oversaw the swift prosecution of Mr. da Silva on corruption and money laundering charges.The conviction, upheld by an appeals court early this year, rendered Mr. da Silva ineligible to run for office. Mr. da Silva, who served two terms as president and left office in 2010 with a record approval rating, was at one point the front-runner in this year’s presidential contest. Now, he is serving a 12-year sentence and considers himself a political prisoner.“Fraud of the century!” Senator Gleisi Hoffmann, the head of Mr. da Silva’s Workers’ Party wrote on Twitter in response to Mr. Moro’s appointment. She charged that Mr. Bolsonaro, a far-right politician, “only got elected because Lula was unfairly convicted and prevented from participating in the elections.”Mr. Bolsonaro on Sunday handily defeated Fernando Haddad, the candidate the Workers’ Party put forward in the final weeks of the campaign after it became clear Mr. da Silva could not run.Mr. Moro and Mr. Bolsonaro discussed the terms of the job during a meeting at Mr. Bolsonaro’s home in Rio de Janeiro on Thursday morning.Mr. Moro said the job presented him with a unique opportunity to “consolidate and broaden” Brazil’s movement to stamp out corruption. He said his decision should not call into question the impartiality of the judiciary.“As a judge, my rulings speak for themselves, and they are substantiated,” he wrote in a text message. “Almost all of them have been upheld on appeal. So it’s not just the work of one person. I think people will understand that.”Joining Mr. Bolsonaro’s administration may enable Mr. Moro, 46, to sell reluctant lawmakers on a series of anti-corruption measures that members of the judiciary have sought over several years.But tying his lot to Mr. Bolsonaro, a deeply polarizing figure, could hurt Mr. Moro’s reputation and weaken confidence in the judiciary, analysts said.Mr. Bolsonaro has exalted the country’s military dictatorship and has endorsed a draconian approach to restoring security, which critics say amounts to an endorsement of extrajudicial killings.Mr. Moro took several actions during the final months of the campaign that stood to help Mr. Bolsonaro. They included making public last month the testimony of a former minister who had implicated Mr. da Silva in corruption.“In the short term, the optics are not very positive,” said Matthew Taylor, a professor at American University who has interviewed Mr. Moro as part of his research into corruption in Brazil. Referring to the Workers’ Party by its Portuguese initials, he added: “It plays into the P.T.’s narrative of a rigged playing field and a judiciary that is partisan.”Still, Mr. Taylor and other analysts said the strategic smarts that made Mr. Moro a successful judge may bring about positive changes.“Moro is more than qualified to be the minister of justice,” said Roberta Braga, a Brazil expert at the Atlantic Council. “It bodes well for passing structural anti-corruption reforms.”Mr. Moro’s name had been floated as a presidential contender in recent years, but he said repeatedly and emphatically that he intended to steer clear of politics.Joice Hasselmann, a journalist who wrote a biography of Mr. Moro and was elected to Congress last month, said Mr. Moro overcame his reservations about entering politics because “he felt the responsibility when he was called upon.”Ms. Hasselmann, a staunch ally of Mr. Bolsonaro, said Mr. Moro was assured that he will have the freedom to pursue corruption without political interference. His arrival in the capital, Brasilía, will be greeted with fear by much of the old guard, she predicted.“I’m sure several of the political chieftains are despairing,” Ms. Hasselmann said in an interview. “They will have someone very close who can cross the street and haul them to jail.”Mr. Moro has written extensively about anti-corruption campaigns in other countries, including in Italy. In the text message, he drew a parallel between his career and that of the Italian judge Giovanni Falcone, who took on the Sicilian Mafia during the 1980s. Mr. Falcone was assassinated by mob leaders in 1992.“The celebrated Italian jurist, who was far better than I, also left the bench and went to work at the justice ministry, having grasped the need for broader measures against the Mafia,” Mr. Moro wrote.