Michael Cohen, Trump’s former longtime personal attorney, pleads guilty to illegal campaign contributions 'at the direction of a candidate for federal office' Cohen had reached a plea deal with federal prosecutors.

Michael Cohen, the former longtime fixer and personal attorney for Donald Trump, appeared in federal court in New York Tuesday afternoon, pleaded guilty to eight counts and said that he made illegal campaign contributions "in coordination and at the direction of a candidate for federal office."

The "candidate" Cohen referred to was not named in court or in the criminal information charging document but one of Cohen's lawyers, Lanny Davis, later said that Cohen had "testified under oath that Donald Trump directed him to commit a crime."

The campaign finance violations are associated with Cohen’s role in alleged hush money agreements with two women, Stormy Daniels and Karen McDougal, who claim to have had affairs with Trump.

While the criminal information does not name Trump, the document does identify Cohen as the personal attorney "to Individual-1, who at that point had become the President of the United States."

The information states that Cohen made a contribution to "Individual-1" and "did so by making and causing to be made an expenditure, in cooperation, consultation, and concert with, and at the request and suggestion of one or more members of the campaign, to wit, COHEN made a $130,000 payment to Woman-2 to ensure that she not publicize damaging allegation before the 2016 presidential election and thereby influence that election."

“I participated in this conduct for the principal purpose” of influencing an election, Cohen said.

The president's current personal attorney, Rudy Giuliani, was quick to react.

"There is no allegation of any wrongdoing against the President in the government's charges against Mr. Cohen. It is clear that, as the prosecutor noted, Mr. Cohen's actions reflect a pattern of lies and dishonesty over a significant period of time,” Giuliani said in a statement.

Davis, Cohen's lawyer, countered: "Michael Cohen took this step today so that his family can move on to the next chapter."

"This is Michael fulfilling his promise made on July 2nd to put his family and country first and tell the truth about Donald Trump," Davis continued, referring to comments Cohen made in an interview with ABC News Chief Anchor George Stephanopoulos.

"Today he stood up and testified under oath that Donald Trump directed him to commit a crime by making payments to two women for the principal purpose of influencing an election. If those payments were a crime for Michael Cohen, then why wouldn't they be a crime for Donald Trump?” Davis said.

Cohen, wearing a dark suit and yellow tie, came in looking relaxed and even appeared to wink at the journalists behind him, but he stiffened as the hearing proceeded.

The federal judge asked him numerous questions about waiving his rights and addressed his competency to do so.

Cohen responded that “in four days I’ll be 52.” He said he hasn’t been treated for psychological problems or addiction but said “last night I had a glass of Glenlivet 12 on the rocks,” referring to the pricey, single malt Scotch whiskey, which he said was not his custom.

Your browser does not support iframes.

Cohen had agreed to a deal with federal prosecutors in the Southern District of New York that required him to plead guilty to the violations of campaign finance law as well as several felony charges of bank fraud and tax evasion.

The tax charges stem from Cohen’s personal business dealings and investments in real estate and the taxi industry.

When the federal judge asked Cohen if he understood that he could get a maximum sentence of 65 years in prison if sentenced consecutively, Cohen said “yes.”

The government estimates Cohen would face some significant prison time under the deal, which will also require Cohen to make a substantial monetary forfeiture.

Though Cohen has been for weeks publicly signaling a willingness to consider a cooperation pact with authorities, it is unclear if there is a provision in the deal that requires Cohen to cooperate in ongoing federal investigations, either in New York or in Special Counsel Robert Mueller’s investigation into Russian interference in the 2016 presidential election.

There was no immediate indication of a cooperation agreement with the government -- but the absence of a cooperation deal - while it would be notable - would not completely eliminate the possibility that Cohen could subsequently provide information to investigators that might result in a more lenient sentence.

Given Cohen’s proximity to Trump during the past decade, including throughout his meteoric rise from mogul and reality television star to the White House, observers consider him one of most potent legal thorns to confront Trump’s presidency since he took office.

“The guy who knows where all the bodies are buried,” said Seth Hettena, an author and veteran journalist who has chronicled Trump’s business career.

The investigation into Cohen was referred to New York’s Southern District by special counsel Robert Mueller, and if Cohen agrees to cooperate, the information he provides could benefit the investigation into Russian meddling in the 2016 election. But it remains unclear if he has committed to cooperate.

Cohen’s relationship with Trump dates to the mid-2000’s after Cohen, who owned condominiums in multiple Trump buildings in New York, took Trump’s side in a legal dispute with the condo board at Trump World Tower on Manhattan’s East Side. Cohen eventually went to work for the Trump Organization, where he held the positions of executive vice president and special counsel to Donald J. Trump.

"Michael Cohen has great insight into the real estate market," Trump said of Cohen in a 2007 New York Post interview. "He has invested in my buildings because he likes to make money – and he does."

In addition to working inside the Trump Organization as a lawyer and problem solver, Cohen built a diverse portfolio of investments.

At one point that included running 260 yellow cabs with a Ukrainian-born partner – a partnership that ended in 2012. He also invested millions in real estate, often turning a tidy profit. For instance, a building he bought in 2011 on the Lower East Side of Manhattan for $2.1 million, sold three years later for $10 million in cash.

The FBI raid on Cohen’s home and office in April gave the most significant indication his business dealings could become a legal problem for him.

For more than a decade around the office in Trump Tower – and around New York – Cohen’s loyalty to Trump was unquestioned as he developed a reputation as Trump's "pit bull."

"It means that if somebody does something Mr. Trump doesn't like, I do everything in my power to resolve it to Mr. Trump's benefit," Cohen said in a 2011 interview with ABC News. "If you do something wrong, I'm going to come at you, grab you by the neck and I'm not going to let you go until I'm finished."

In 2010, Cohen was among the creators of a website, ShouldTrumpRun.org, that sought to encourage the New York real estate tycoon and reality television star to pursue a challenge to President Barrack Obama in the 2012 election.

"I think the world of [Trump]," Cohen told ABC News in the 2011 interview. "I respect him as a businessman, and I respect him as a boss."

Cohen’s dealings at the Trump family business covers a broad sweep of its global empire – including several projects that have caught the attention of federal investigators. Cohen played an integral role in early discussions about a possible Trump Tower in Moscow – negotiations that were going on during the early months of the 2016 presidential campaign.

That deal never reached fruition.

“He could be extremely valuable,” said Matthew G. Olsen, a former federal prosecutor and ABC News contributor. “He was not just a personal lawyer but also was President Trump’s so-called fixer for a number of years. So he would have had access to lots of very personal information involving his business dealings.”

In January - the Wall Street Journal first revealed Cohen’s role in negotiating a secret non-disclosure agreement with adult-film actress Stephanie Clifford, aka Stormy Daniels. The deal – which was executed less than two weeks prior to the November presidential election – paid Daniels $130,000 in exchange for her silence.

Government watchdog groups quickly filed complaints with the Federal Election Commission and the Department of Justice, asking the agencies to investigate for possible violations of campaign finance law.

Following the disclosure of the Daniels’ deal, Cohen insisted that he had acted on his own in the Daniels deal and that he had not been reimbursed by the campaign or the Trump Organization.

He told ABC News that the funds used to pay Daniels came from an existing home equity line of credit.

Two sources familiar with the search warrant that led to the raids on Cohen properties told ABC News in April that federal agents were hunting for records tied to Cohen’s personal business dealings and secret deals with Trump's alleged mistresses, media organizations during the 2016 presidential campaign.

On April 5, four days before the authorities raided Cohen’s properties in New York, President Trump told reporters on Air Force One that he didn’t know why Cohen had paid Daniels or where he had gotten the money to pay her. The president later acknowledged, in a financial disclosure form filed last month with the Office of Government Ethics, that he had reimbursed Cohen.

Then there is Karen McDougal, who in August 2016 signed a $150,000 deal with American Media Inc., the publisher of the National Enquirer, that transferred to the company the rights to her story of an alleged ten-month romantic affair with Trump in 2006. The magazine never published her story. McDougal alleged in a lawsuit filed earlier this year that Cohen had allegedly conspired with her former attorney to bury the story. McDougal settled her lawsuit.

President Trump, through his representatives, has denied the allegations of McDougal and Daniels.

ABC News' Aaron Katersky and Josh Margolin contributed to this report.

"It means that if somebody does something Mr. Trump doesn't like, I do everything in my power to resolve it to Mr. Trump's benefit," Cohen said in a 2011 interview with ABC News. "If you do something wrong, I'm going to come at you, grab you by the neck and I'm not going to let you go until I'm finished."

In 2010, Cohen was among the creators of a website, ShouldTrumpRun.org, that sought to encourage the New York real estate tycoon and reality television star to pursue a challenge to President Barrack Obama in the 2012 election.

"I think the world of [Trump]," Cohen told ABC News in the 2011 interview. "I respect him as a businessman, and I respect him as a boss."

Cohen’s dealings at the Trump family business covers a broad sweep of its global empire – including several projects that have caught the attention of federal investigators. Cohen played an integral role in early discussions about a possible Trump Tower in Moscow – negotiations that were going on during the early months of the 2016 presidential campaign.

That deal never reached fruition.

“He could be extremely valuable,” said Matthew G. Olsen, a former federal prosecutor and ABC News contributor. “He was not just a personal lawyer but also was President Trump’s so-called fixer for a number of years. So he would have had access to lots of very personal information involving his business dealings.”

In January - the Wall Street Journal first revealed Cohen’s role in negotiating a secret non-disclosure agreement with adult-film actress Stephanie Clifford, aka Stormy Daniels. The deal – which was executed less than two weeks prior to the November presidential election – paid Daniels $130,000 in exchange for her silence.

Government watchdog groups quickly filed complaints with the Federal Election Commission and the Department of Justice, asking the agencies to investigate for possible violations of campaign finance law.

Following the disclosure of the Daniels’ deal, Cohen insisted that he had acted on his own in the Daniels deal and that he had not been reimbursed by the campaign or the Trump Organization.

He told ABC News that the funds used to pay Daniels came from an existing home equity line of credit.

Two sources familiar with the search warrant that led to the raids on Cohen properties told ABC News in April that federal agents were hunting for records tied to Cohen’s personal business dealings and secret deals with Trump's alleged mistresses, media organizations during the 2016 presidential campaign.

On April 5, four days before the authorities raided Cohen’s properties in New York, President Trump told reporters on Air Force One that he didn’t know why Cohen had paid Daniels or where he had gotten the money to pay her. The president later acknowledged, in a financial disclosure form filed last month with the Office of Government Ethics, that he had reimbursed Cohen.

Then there is Karen McDougal, who in August 2016 signed a $150,000 deal with American Media Inc., the publisher of the National Enquirer, that transferred to the company the rights to her story of an alleged ten-month romantic affair with Trump in 2006. The magazine never published her story. McDougal alleged in a lawsuit filed earlier this year that Cohen had allegedly conspired with her former attorney to bury the story. McDougal settled her lawsuit.

President Trump, through his representatives, has denied the allegations of McDougal and Daniels.

ABC News' Aaron Katersky and Josh Margolin contributed to this report.

President Trump, through his representatives, has denied the allegations of McDougal and Daniels.

ABC News' Aaron Katersky and Josh Margolin contributed to this report.