NEW YORK — A federal judge on Wednesday sentenced President Trump’s former attorney Michael Cohen to three years in prison for financial crimes and lying to Congress, as the disgraced “fixer” apologized but said he felt it was his duty to cover up the “dirty deeds” of his former boss.

Cohen made an emotional apology to U.S. District Judge William H. Pauley III, taking responsibility for what the judge called a “veritable smorgasbord of criminal conduct” — crimes that included tax violations, lying to a bank and, during the 2016 campaign, buying the silence of women who claimed that they once had affairs with the future president.

The downfall of the hard-charging, high-profile lawyer has potential consequences far beyond Cohen, as authorities have alleged that Trump directed him in violating campaign finance laws. Facing his day of reckoning, Cohen laid plenty of the blame at the president’s feet, and his lawyer said he would continue to cooperate with the ongoing special counsel investigation of the president’s campaign.

“My weakness could be characterized as a blind loyalty to Donald Trump,” Cohen told the packed courtroom. He sniffled and fought back tears as he spoke, pausing occasionally to regain his composure.

Cohen had faced as much as five years and three months in prison, but Pauleysaid the sentence should reflect two key elements of Cohen’s case — punishing those who repeatedly break the law while rewarding those who cooperate and provide truthful testimony. Cohen has provided information to investigators about Trump and the Trump campaign, but prosecutors said he refused to tell them everything he knew.

Michael Cohen, right, President Trump's former attorney and “fixer,” is accompanied Wednesday by his wife and children as he arrives at the federal courthouse in New York for his sentencing hearing. (Craig Ruttle/AP)

A special counsel’s office prosecutor emphasized in court that the man who once fondly considered himself Trump’s fixer has provided useful information that speaks to the core mission of Robert S. Mueller III: determining whether anyone in the Trump campaign coordinated with Russia to influence the election. That is worrisome for Trump. But, as it has throughout the investigation, Mueller’s team held its cards close, not revealing any new details about what it had learned from Cohen, or where the probe might be headed next.

The judge ordered Cohen to begin serving his sentence on March 6 and recommended he be sent to a federal prison in Otisville, N.Y. He also told Cohen, a multimillionaire who owns pricey real estate and a taxi medallion business, to pay nearly $2 million in financial penalties.

“Our democratic institutions depend upon the honesty of our citizenry in dealing with the government,” Pauley said, calling Cohen’s crimes serious, particularly given his profession.

“As a lawyer, Mr. Cohen should have known better,” the judge said. “While Mr. Cohen is taking steps to mitigate his criminal conduct by pleading guilty and volunteering useful information to prosecutors, that does not wipe the slate clean.

“Mr. Cohen selected the information he disclosed to the government,” Pauley said. “This court cannot agree with the defendant’s assertion that no jail time is warranted. In fact, this court firmly believes that a significant term of imprisonment is fully justified in this highly publicized case to send a message.”

Trump made no immediate statements after the sentencing, but he told Reuters on Tuesday that the payments made to buy women’s silence did not violate criminal campaign finance laws.

“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. Okay?” Trump told the news organization.

The president also sought to cast blame on Cohen.

“Michael Cohen is a lawyer. I assume he would know what he’s doing,” Trump said.

Cohen pleaded guilty in two separate cases. One was brought by Mueller, over Cohen’s lies to Congress about a possible Trump Tower project in Moscow that he pursued in the heat of Trump’s presidential campaign. The other was brought by federal prosecutors in New York over tax and bank fraud allegations, as well as campaign finance violations.

Separately, New York prosecutors announced Wednesday that they had struck a non-prosecution agreement with AMI, the company that produces the National Enquirer tabloid, for its role in squelching stories of women who said they had relationships with Trump. AMI paid $150,000 to one of the women before the 2016 election. As part of the agreement, AMI admitted it made the payment principally “in concert” with Trump’s campaign to “suppress the woman’s story so as to prevent it from influencing the election,” according to a statement from the U.S. Attorney’s Office for the Southern District of New York.

In his appeal for leniency, Cohen, dressed in a charcoal suit and light blue tie, denounced what he called his own weakness in the service of his former boss, the president.

“I stand before your honor humbly and painfully aware that we are here today for one reason, because of my actions that I pled guilty to,” Cohen said. “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 said there was a deep irony about his sentencing, because he felt that he was finally getting free from Trump. “Today is the day I am getting my freedom back as you sit at the bench and contemplate my fate,” he said. “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. In fact I now know there is little to be admired.”

He cited a recent tweet from the president calling Cohen “weak” for cooperating with the government and said the president was right, but not in the way he meant.

“It was my own weakness and a blind loyalty to this man that led me to choose a path of darkness over light,” Cohen said. “Time and time again, I felt it was my duty to cover up his dirty deeds.”

Cohen was joined in court by his parents, his wife, his children and other family members. He entered the courtroom locked arm-in-arm with his daughter, who walked with a single crutch. Upon leaving, he strode past a bank of television cameras, ignoring a microphone stand that had been set up, and departed in a black SUV. Moments later, Michael Avenatti, the attorney for one of the women whom Cohen arranged to be paid hush money, told reporters Cohen “deserved every day of the 36-month sentence” he received.

Cohen attorney Guy Petrillo urged the judge to be lenient in light of what he called Cohen’s courage and “the remarkable nature and significance” of his decision to cooperate against Trump.

“He knew that the president might shut down the investigation. . . . He came forward to offer evidence against the most powerful person in our country,” Petrillo said. “He did so not knowing what the result would be, not knowing how the politics would play out, not knowing if the special counsel would even survive.”

As a result, Petrillo said, Cohen and his family have faced public outrage and threats.

“This is not a case of standard cooperation,” Petrillo said, calling the investigation in question as significant as the Watergate probe involving President Richard M. Nixon more than 40 years ago.

Petrillo also criticized prosecutors, suggesting that Cohen would not have faced such harsh consequences but for his famous client. He said the New York prosecutors, in particular, were taking such an aggressive posture out of “pride.”

“No other defendant would be treated in this fashion,” Petrillo said. “Mr. Cohen has the misfortune of having been counsel to the president.”

The lawyer said Cohen is willing to cooperate further with the FBI and said it was unfair for prosecutors to say he is refusing to discuss other possible crimes he may know about. There was no indication from either side that such cooperation might lead to another sentence reduction.

Trump and his legal team have sought to downplay Cohen’s allegations, and the president had said Cohen deserves a “full and complete” sentence. Trump has denied having the affairs and this week accused his political opponents of focusing on the campaign finance matter because, the president claimed, they had failed to prove his campaign coordinated with Russia to influence the election.

Jeannie Rhee, part of Mueller’s prosecution team, told the judge that Cohen “has endeavored to account for his criminal conduct in numerous ways,” providing “credible and reliable information about core Russia-related issues under investigation.”

Rhee said she could not go into detail about the ongoing Russia investigation but said Cohen was “helpful” to the probe. Cohen, she said, was “careful to note what he knows and what he doesn’t know. . . . Mr. Cohen has sought to tell us the truth, and that is of utmost value to us.”

The special counsel’s office, for its part, seems to view Cohen as a valuable cooperator. Mueller’s prosecutors did not recommend any particular punishment in their case but said he should not serve any additional prison time beyond his sentence in the New York case.

They credited Cohen with providing “useful information” about the ongoing probe of Russian interference in the 2016 election, as well as “relevant information” about his contacts with people connected to the White House between 2017 and 2018.