Michael Cohen was sentenced to three years in prison after pleading guilty to a series of charges, including a campaign finance violation in which he implicated President Trump.

In an appearance in a New York federal court before his sentencing, Cohen said that he was sorry for his crimes, explaining that when he served as Donald Trump’s personal lawyer, it was “my duty to cover up his dirty deeds,” according to CNN.

“I take full responsibility for each act that I pled guilty to, the personal ones to me and those involving the president of the United States of America,” Cohen told the court, CNN reported. Cohen was also sentenced to three years of supervised release, and is scheduled to report to serve his term on March 6.

When he pled guilty to a series of crimes in August, Cohen implicated Trump in an effort to pay hush money in 2016 to Stormy Daniels and Karen McDougal, who claimed to have affairs with the real estate mogul. Cohen plead guilty to counts of violating campaign finance laws, as well as charges that included tax evasion and lying to Congress and a financial institution.

Trump and his legal team have called Cohen a liar, and the president himself has minimized the nature of the campaign finance violations. The president also has blasted Cohen, calling him “very weak.”

But at the sentencing hearing, Cohen told the court, “Recently the president tweeted a statement calling me weak and it was correct, but for a much different reason than he was implying. It was because time and time again I felt it was my duty to cover up his dirty deeds.”

Cohen’s legal team asked the judge for leniency, noting that he has provided information to special counsel Robert Mueller in his Russia investigation.

But Cohen has no cooperation agreement with federal prosecutors, who argued that he should face “substantial” prison time. They had recommended at least 3.5 years in prison.

“After cheating the IRS for years, lying to banks and to Congress, and seeking to criminally influence the presidential election, Cohen’s decision to plead guilty, rather than seek a pardon for his manifold crimes, does not make him a hero,” prosecutors said in a court filing last week.

“Michael Cohen is no hero. He is no patriot,” Michael Avenatti, Daniels’ attorney, told reporters after the sentencing, adding that as Trump’s attorney, Cohen engaged in tactics of intimidating his client.

“Michael Cohen was sentenced today. Donald Trump is next.”

Cohen was once fiercely loyal to Trump, and once said that he would “take a bullet for the president.”

But that changed after federal agents raided his home and office in April and seized files and electronic devices. Prosecutors zeroed in on a series of criminal claims, and eventually charged him with nine counts. Cohen pleaded guilty to a series of charges in September, and then to another last month.

The latter charge had to lying to Congress over the timeline of when Cohen had discussed the development of a Trump Tower in Russia with officials linked to Russian President Vladimir Putin. Initially, Cohen had said those talks ended before 2016, when in fact they extended well into 2016, as Trump secured the Republican nomination.

In an interview with Reuters this week, Trump pushed back against the notion that he faces legal liability for a crime.

“Number one, it wasn’t a campaign contribution. If it were, it’s only civil, and even if it’s only civil, there was no violation based on what we did. OK?” he said.