WASHINGTON — When Alan M. Dershowitz told President Trump this week that he would join the legal team for his impeachment trial in the Senate, his transformation from a onetime liberal standard-bearer into a conservative provocateur appeared to be complete.

Mr. Dershowitz, 81, a professor emeritus at Harvard Law School, prides himself on being a civil libertarian and a contrarian who isn’t afraid to defend the seemingly indefensible, especially if that person has a high-profile, tabloid-friendly name. His past clients include Claus von Bülow, O.J. Simpson, Mike Tyson and Jeffrey Epstein, the wealthy financier who was accused of sex trafficking and killed himself last year in a Manhattan jail.

Earlier in his career, Mr. Dershowitz was also known as an advocate for the First Amendment who defended neo-Nazi speech and pornography and served on the board of the American Civil Liberties Union. Back then, according to The New Yorker, he also worked pro bono to represent clients involved in challenges to censorship and the death penalty.

Mr. Dershowitz’s connections to Mr. Epstein, however, have proved the most complicating in recent years. In 2014, one of Mr. Epstein’s victims, Virginia Giuffre, said in a court filing that Mr. Dershowitz was one of the Epstein friends to whom she was offered for sex.