A judge has sentenced Michael Cohen, the president’s former personal attorney, to 36 months in prison. 

Speaking before the court, Cohen accused President Trump of causing him to “follow a path of darkness rather than light” and “cover up his dirty deeds,” according to a Newsday reporter inside the courtroom.

Prosecutors in the Justice Department’s Southern District of New York charged Cohen with eight felony counts in August, including tax evasion, making false statements to a financial institution, and campaign finance violations.

Special counsel Robert Mueller, tasked with investigating Russian interference in the 2016 presidential election, tacked on an additional count of lying to Congress last month.

Cohen pleaded guilty to all nine counts.

In court on Wednesday, a New York prosecutor, Nicolas Roos, argued that Cohen “cannot have it both ways,” according to a reporter with Courthouse News in the courtroom.

In court documents filed last week, federal prosecutors in New York argued Cohen should serve a “substantial term of imprisonment” for the crimes to which he has pleaded guilty.

"The charges portray a pattern of deception, of brazenness and of greed," Roos said. “Cohen has eroded faith in the electoral process.”

Cohen’s attorney, Guy Petrillo, sought to paint his client in a different light, arguing that Cohen “came forward to offer evidence against the most powerful person in the country,” according to a reporter with Courthouse News in the courtroom.

Federal prosecutors allege that Cohen violated campaign finance laws by paying off two women who allege to have had affairs with Donald Trump acting “in coordination with and at the direction of” the then-candidate.

Trump has argued the payments amount to nothing more than a “simple private transaction,” and do not qualify as campaign finance violations.

With the pounding of his gavel on Wednesday morning, U.S. Judge William Pauley in Manhattan will mark the conclusion of Cohen’s improbable journey from Trump’s legal counsel to perhaps the most potent vehicle for President Trump’s legal exposure.

For more than a decade, Cohen stood by Trump’s side as a personal attorney, fixer and confidant, famously proclaiming that he would “take a bullet for the president” and “never walk away.”

But over the past year, as investigators targeted his personal finances, Cohen flipped on his former boss and cooperated in multiple investigations, including Mueller's probe, targeting Trump’s campaign and family business operations.

Cohen faced up to 63 months -- or more than five years -- in prison for the crimes committed, but Judge Pauley will consider a lesser sentence given Cohen’s cooperation with investigators.