President Donald Trump’s former fixer, Michael Cohen, was sentenced Wednesday to three years in prison for lying to Congress, illegal hush-money payments to a porn star and a Playboy model, and other crimes.

Before he was sentenced, an emotional Cohen said he took full responsibility and that “blind loyalty” to Trump had led him to “choose a path of darkness over light” and that his loyalty had been repaid with scorn and insults.

He said he would cooperate with ongoing investigations even though he refused to sign a cooperation agreement, and his Washington attorney said he is willing to appear before Congress.

“Today is one of the most meaningful days of my life. The irony is today is the day I’m getting my freedom back,” Cohen told the judge before he learned his fate, with his wife and kids, parents and in-laws sitting in the Manhattan courtroom.

“I have been living in a personal and mental incarceration ever since the fateful day that I accepted the offer to work for a famous real estate mogul whose business acumen I truly admired,” Cohen continued.

“Recently, the president tweeted a statement calling me weak, and he was correct, but for a much different reason than he was implying,” Cohen said, choking up at times. “It was because time and time again I felt it was my duty to cover up his dirty deeds rather than to listen to my own inner voice and my moral compass.”

Cohen—who was also ordered to pay more than $2 million in fines, restitution, and forfeiture—was not immediately jailed and left the courthouse without comment. He will voluntarily surrender March 6.

Attorney Lanny Davis said in a statement that Cohen is not done talking about his ex-boss and will “state publicly all he knows” once the investigations are wrapped up. “Mr. Trump’s repeated lies cannot contradict stubborn facts,” Davis said.

The sentencing covered two cases: one brought by the U.S. Attorney's Office in Manhattan, the other by Special Counsel Robert Mueller, who is probing Russian interference in the 2016 election and possible collusion by the Trump campaign.

In the Manhattan case, Cohen had pleaded guilty to breaking campaign finance law by doling out hush money to Stormy Daniels and Karen McDougal, who claim they had affairs with Trump. (In a related move, prosecutors announced later they struck a non-prosecution deal with National Enquirer publisher American Media Inc. in which the company admits it funneled money to McDougal so she would stay quiet until the election). Cohen also admitted to hiding millions from the IRS and lying on a bank loan application.

In the case brought directly by Mueller, Cohen pleaded guilty to lying to Congress about the extent of plans for a Trump Tower in Moscow in 2016 and responses from the Kremlin about the project.

The maximum Cohen faced was 69 months in prison in both cases. Manhattan prosecutors called for 42 months, saying he had refused to fully cooperate, while Mueller’s team called for no extra time.

Judge William Pauley insisted he serve a “significant” sentence—36 months—as he excoriated him from the bench for losing his “moral compass.”

“His entire professional life apparently revolved around the Trump Organization. He thrived on his access to wealthy and powerful people and he became one himself,” Pauley said.

Although it was not part of the case, after Trump was elected, Cohen collected millions in consulting payments from companies including Novartis, AT&T, Korea Aerospace Industries, and Columbus Nova, which has ties to Ukranian-born Russian oligarch Viktor Vekselberg.

“ I have been living in a personal and mental incarceration ever since the fateful day that I accepted the offer to work for a famous real estate mogul whose business acumen I truly admired. ” — Michael Cohen

Cohen—who once bragged he would “take a bullet” for Trump—had asked for a no-jail sentence because of his cooperation with Mueller.

“He came forward to offer evidence against the most powerful person in our country,” his defense attorney, Guy Petrillo, told the court, adding that his client had “the misfortune” of being Trump’s counsel.

“He did so not knowing what the result would be, not knowing how the politics would play out, and not knowing whether the special counsel would even survive.”

In a sentencing memo last week, Mueller praised Cohen’s “substantial and significant” help in offering information about the Trump Organization’s plans for a Trump Tower in Moscow and efforts by a Russian national to set up a meeting between Trump and Russian President Vladimir Putin during the 2016 campaign.

“He has provided our office with credible and reliable information about core Russia-related issues under investigation and within the purview of the Special Counsel's Office,” Jeannie Rhee, a prosecutor on Mueller's team, told the judge.

“There's only so much that we can say about the particulars at this time given our ongoing investigation, but we hope that we have sufficiently outlined for the court that they were ranging and that they were helpful.”

However, the Manhattan-based prosecutors took a dimmer view of Cohen’s helpfulness. In court filings, Deputy U.S. Attorney Robert Khuzami said his assistance was “overstated” and “incomplete” and that he had only agreed to help out the Russia investigation once it was clear he was about to be charged on tax evasion, bank fraud, and campaign finance violations.

“Collectively, the charges portray a pattern of deception, of brazenness and greed,” Assistant U.S. Attorney Nicholas Roos said in court.

Petrillo said Cohen has every intention of answering questions going forward but did not want to sign a long-term cooperation agreement “for personal reasons.”

“He wants both to remove himself and to remove his family from the glare of the cameras and try to work his way and their way back from an abnormal life,” the lawyer said.

"Michael has owned up to his mistakes and fully cooperated with Special Counsel Mueller in his investigation," Davis said. "While Mr. Mueller gave Michael significant credit for cooperation on the "core" issues, it is unfortunate that SNDY prosecutors did not do the same." He added: "To me, their judgment showed a lack of appropriate proportionality."

Cohen’s sentencing may not mark the end of the Justice Department’s interest in the 2016 campaign finance violations.

When he pleaded guilty, Cohen told a Manhattan court the payouts were made “at the direction” of then-candidate Trump, an allegation later echoed by Khuzami in a sentencing memo.

Those claims have raised the question of Trump’s own criminal liability in the hush-money scheme—the president says that as his attorney, Cohen is responsible for any illegal moves—but current Justice Department policy bars prosecutors from indicting a sitting president.

The New York Times has reported that prosecutors are still investigating Trump Organization executives for their potential role in the alleged mistress payouts.

Cohen’s cooperation with Mueller also raises questions about the next steps in the Russia investigation. His timeline of plans for a Trump Tower Moscow raises the possibility that Russia may have tried to use the project to influence the 2016 election.

While other Trump associates charged in the course of the Russia investigation have angled for presidential pardons, Cohen’s chances of getting relief from his former boss are slim. Trump has praised Paul Manafort, who clashed repeatedly with the special counsel’s office, as a “brave man” and said a pardon for his former campaign manager is “not off the table.”

But in tweets and interviews, Trump has blasted Cohen as a “liar” who deserves to serve a “full and complete sentence.”