It was about an hour into Harvey Weinstein’s rape trial when his lead defense lawyer came under attack. The prosecutor called a recent media blitz intended to discredit Mr. Weinstein’s accusers “an abomination” and asked the judge to put an end to it with a gag order.

But the defense lawyer, Donna Rotunno, lashed back at the prosecutor, Joan Illuzzi.

“Ms. Illuzzi stands in this courtroom and calls my client a predator and then has the nerve to say I shouldn’t go out and discuss this case,” Ms. Rotunno said. “She wants everyone out there to convict Mr. Weinstein before one piece of evidence comes before this court.”

Long before an avalanche of allegations against Mr. Weinstein set off a global reckoning over sexual harassment, Ms. Rotunno was steadily building a career as a criminal lawyer in Chicago with an unusual specialty: defending men accused of sex crimes.

As the #MeToo movement grew, she embraced the role of contrarian, arguing that a public rush to condemn men accused of sexual misconduct and assault was shredding reputations and careers without due process. Even if the movement had helped the feminist cause, she said, it came at too high a price.