Donald Trump has scrambled to distance himself from illegal campaign contributions made by his former lawyer to two women who allege they had affairs with the president more than a decade ago.

Michael Cohen, Mr Trump’s former personal lawyer, was sentenced to three years in prison on Wednesday, in part for funnelling money – allegedly at the direction of the president – to porn star Stormy Daniels and former Playboy model Karen MacDougal.

“I never directed Michael Cohen to break the law. He was a lawyer and he is supposed to know the law,” Mr Trump tweeted on Thursday morning. “It is called ‘advice of counsel,’ and a lawyer has great liability if a mistake is made. That is why they get paid.”

“Despite that many campaign finance lawyers have strongly stated that I did nothing wrong with respect to campaign finance laws, if they even apply, because this was not campaign finance,” he continued. “Cohen was guilty on many charges unrelated to me, but he plead to two campaign charges which were not criminal and of which he probably was not guilty even on a civil basis.”

The president’s comments arrived after Cohen admitted on Wednesday to covering up Mr Trump’s “dirty deeds” out of “blind loyalty,” closing his eyes as a judge pronounced his sentence for evading $1.4m in taxes, lying about Trump’s business dealings in Russia and violating campaign-finance laws in buying the silence of multiple women during the 2016 election.

“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,” said a choked-up Cohen, a lawyer who once boasted he would “take a bullet” for Trump. “My weakness can be characterised as a blind loyalty to Donald Trump, and I was weak for not having the strength to question and to refuse his demands.”

Cohen is the first and, so far, only member of Trump’s circle during two years of investigations to go into open court and implicate him in a crime, though whether a president can be prosecuted under the constitution is an open question.

However, the president rejected Cohen’s accusations on Thursday, writing: “Those charges were just agreed to by him in order to embarrass the president and get a much reduced prison sentence, which he did-including the fact that his family was temporarily let off the hook.”

Who could be running against Trump in 2020? Show all 23 1 /23 Who could be running against Trump in 2020? Who could be running against Trump in 2020? Joe Biden The former vice president - poised to be a frontrunner - has announced his run. He recently faced scrutiny for inappropriate touching of women, but was thought to deal with the criticism well AFP/Getty Who could be running against Trump in 2020? Bernie Sanders The 2016 runner-up has announced that he will be running again in 2020 Getty Who could be running against Trump in 2020? Hillary Clinton The 2016 Democratic presidential candidate and former Secretary of State says she is “still considering” whether she will run again. Getty Who could be running against Trump in 2020? Pete Buttigieg The Indiana mayor and war veteran will be running for president. If elected, he would be the first openly LGBT+ president in American history. Getty Who could be running against Trump in 2020? Kamala Harris The former California attorney general will be running for president in 2020. Introduced to the national stage during Jeff Sessions’ testimony, she has endorsed Medicare-for-all and proposed a major tax-credit for the middle class. AP Who could be running against Trump in 2020? Elizabeth Warren The Massachusetts Senator has formally launched her bid for president in 2020. A progressive Democrat, she is a major supporter of regulating Wall Street. AP Who could be running against Trump in 2020? Beto O’Rourke The former Texas congressman told Oprah Winfrey that he “has been thinking about running for presidency”, but stopped short of formally announcing his bid to run in 2020. AFP/Getty Who could be running against Trump in 2020? Wayne Messam Mayor of the city of Miramar in the Miami metropolitan area, Wayne Messam has announced his bid. He intends to run on a progressive platform against the "broken" federal government. He favours gun regulations and was a signatory to a letter from some 400 mayors condemning President Trump's withdrawal from the Paris Climate Accord. Vice News Who could be running against Trump in 2020? Kirsten Gillibrand The New York Senator formally announced her presidential bid in January, saying that “healthcare should be a right, not a privilege.” Getty Who could be running against Trump in 2020? Cory Booker The New Jersey Senator has announced that he will be running for the presidency in 2020. If he secures the nomination he said finding a female vice president would be a priority. Getty Who could be running against Trump in 2020? John Delaney The Maryland congressman was the first to launch his bid for presidency, making the announcement in 2017. AP Who could be running against Trump in 2020? Julian Castro The former San Antonio mayor announced his candidacy in January and said that his running has a “special meaning” for the Latino community in the US. Getty Who could be running against Trump in 2020? Tulsi Gabbard The Hawaii congresswoman announced her candidacy in January, but is likely to face tough questions on her past comments on LGBT+ rights and her stance on Syrian President Bashar al-Assad. Getty Who could be running against Trump in 2020? Andrew Yang The entrepreneur has announced his presidential candidacy, and has pledged that he would introduce a universal basic income of $1,000 a month to every American over the age of 18. AFP/Getty Who could be running against Trump in 2020? Marianne Williamson The author and spiritual advisor has announced her intention to run for president. She had previously run for congress as an independent in 2014 but was unsuccessful. Getty Who could be running against Trump in 2020? John Kerry The former secretary of state has said he is still thinking about whether to run. Getty Who could be running against Trump in 2020? Michael Bloomberg The entrepreneur and former New York mayor– with a net worth of around $50bn – has said he will decide by the end of February whether to seek the presidency. AFP Who could be running against Trump in 2020? Howard Schultz Former Starbucks CEO Howard Schultz has not yet ruled out running for president in 2020, despite criticism that his bid could help re-elect Mr Trump by dividing the Democrat vote. AP Who could be running against Trump in 2020? Eric Holder The former attorney general has said he will decide in “the next month or so” whether to run as a 2020 presidential candidate. AP Who could be running against Trump in 2020? Eric Swalwell The California congressman said he is “ready to do this” and will decide before April whether to run. MSNBC Who could be running against Trump in 2020? Terry McAuliffe The former Virginia governor, who worked to elect Democratic governors during 2018 midterms, said there was a “50 per cent” chance he would run. AP Who could be running against Trump in 2020? Sherrod Brown The Ohio senator is still undecided about whether to run for president in 2020. Who could be running against Trump in 2020? Mitch Landrieu The former New Orleans mayor said he doesn’t think he will run for president, but “never say never”. AP Photo/Jacquelyn Martin

He added: “As a lawyer, Michael has great liability to me!”

In a possible sign of further trouble for the president, Cohen said he will continue cooperating with prosecutors, and one of his legal advisers said Cohen is also prepared to tell “all he knows” to congress if asked.

At the sentencing, defence attorney Guy Petrillo pleaded for leniency for Cohen, saying: “He came forward to offer evidence against the most powerful person in our country.”

US District Judge William H Pauley III said the defendant deserved modest credit, but his assistance “does not wipe the slate clean”.

Support free-thinking journalism and attend Independent events

“Somewhere along the way Mr Cohen appears to have lost his moral compass,” the judge said.

The judge also ordered Cohen to pay $1.39m in restitution to the IRS, forfeit $500,000 and pay $100,000 in fines. He was ordered to report to prison on 6 March and left court without comment.

Mr Trump continued to distance himself from Cohen in an interview with Fox News on Thursday, describing his former lawyer as someone who did “very low-level work” and “was OK on television”.

“I never directed him to do anything wrong. Whatever he did, he did on his own,” he said. “He’s a lawyer. A lawyer who represents a client is supposed to do the right thing, that’s why you pay them a lot of money, etc etc. He is a lawyer.”

Beyond the guilty pleas, it is unclear what Cohen has told prosecutors or what he has left to say, though one of Mueller’s prosecutors, Jeannie Rhee, said in court that Cohen has “provided consistent and credible information about core Russia-related issues under investigation”. Legal experts said Cohen could get his sentence reduced by cooperating.

In the hush-money case, Cohen arranged for American Media Inc, parent of the pro-Trump National Enquirer, to pay $150,000 to McDougal to buy and bury her story, according to prosecutors. Cohen also said he paid $130,000 to Daniels and was reimbursed by Trump’s business empire. Both payments were made during the heat of the 2016 campaign.

Prosecutors said those secret payouts were not reported as campaign contributions and violated the ban on corporate contributions and the $2,700 limit on donations by an individual.