Former FBI Director James Comey revealed Thursday how the private memos detailing his conversations with President Donald Trump became public after he was fired: He asked a "good friend" to leak them.

That confidant is Columbia Law Professor Daniel Richman, friends of Richman confirmed to NBC News. Richman worked with Comey at the university in 2013 when he held a brief research post.

Comey, in testimony to the Senate Select Intelligence Committee, said his decision to have his memos shared publicly came after Trump tweeted last month that Comey had "better hope that there are no 'tapes' of our conversations before he starts leaking to the press!"

James Comey better hope that there are no "tapes" of our conversations before he starts leaking to the press! — Donald J. Trump (@realDonaldTrump) May 12, 2017

Comey testified that he asked "a good friend of mine who's a professor at Columbia Law School" to provide the contents of a memo to an unnamed reporter. He didn't identify Richman to the committee.

Related: Live Blog: Comey Testifies About Trump, Russia

Comey added that because his writings were unclassified he felt he could share them but didn't want to do it personally with the media. "I was worried it would be like feeding seagulls at the beach," he told senators.

Daniel Richman, a professor at Columbia Law School in New York, testifies before the Senate Committee on the Judiciary on Sept. 18, 2007, in Washington. Stephanie Kuykendal / Bloomberg via Getty Images file

Ultimately, he said, he wanted his memo released because "I thought it might prompt the appointment of a special counsel." The day after, it was announced that former FBI Director Bob Mueller would become special counsel.

Comey's discussions with Trump are part of the committee's larger inquiry into alleged Russian meddling in last year's election.

Trump fired Comey on May 9, a week before the memos were leaked. The leaked memo said that Trump had asked him to shut down an investigation into former National Security Adviser Michael Flynn, raising questions about potential obstruction of justice by the president.

Richman and Comey’s ties run deep, and the pair has been friends for 30 years, the law professor told NBC News last fall.

Richman is a former federal prosecutor with the U.S. Attorney's Office for the Southern District of New York and has been a consultant with the Department of Justice and the Department of the Treasury, according to his Columbia biography. Among his areas of expertise are criminal adjudication and federal criminal law.

His bio also lists him as an adviser to Comey and says his "scholarly writings include more than 30 law review articles. He has offered testimony as an expert in a number of congressional hearings, and state, federal, and international criminal and civil matters."

Richman was a vocal supporter of Comey last fall, as the FBI director revealed in October that the bureau was reviewing a new batch of emails linked to Democratic nominee Hillary Clinton that appeared to be pertinent to the earlier investigation into her use of a private server.

"I don't think he takes glee in being contrary for its own sake," Richman told NBC News at the time.

Richman said he’s sure that politics didn’t play a part when Comey decided to re-examine Clinton's emails.

"When you have an obligation to disclose or to qualify, you do it full-stop," Richman added. "You don't worry about timing, you don't worry about how it will be read or spun by others."

Richman could not immediately be reached for comment Thursday.