Michael Cohen, President Donald Trump's former personal attorney, pleaded guilty Tuesday afternoon to eight counts of tax evasion, bank fraud and campaign finance violations, including two counts related to hush-money payments made to women — and said he made the payments "at the direction of a candidate," meaning Trump.

Trump's name didn't come up in the federal courtroom in Manhattan, but Cohen said he had paid two women, apparently porn actress Stormy Daniels and Playboy model Karen McDougal, "at the direction" of an unnamed candidate in 2016, and that a $150,000 payment in August 2016 was for the "principal purpose of influencing" the 2016 presidential election. Both Daniels and McDougal have said they had past relationships with Trump.

Asked if he knew that what he did was illegal, he told the court yes.

Cohen told the court that he and an executive from a media company, at the direction of a federal candidate, arranged to keep one of the alleged affairs from the public with a payment of $150,000. McDougal and her lawyers have said that the National Enquirer, run by Trump associate David Pecker, paid her $150,000 in August 2016 as part of a "catch-and-kill" strategy to keep the story from circulating publicly.

Cohen said in March that he had used money from a home equity loan to pay $130,000 to porn star Stormy Daniels, who has said she had an affair with Trump more than a decade ago.

He told the court Tuesday that after using the money from the loan for the payment, he was reimbursed by the unnamed candidate.

Cohen's sentencing has been scheduled for Dec. 12 at 11 a.m., and Cohen was released on $500,000 bail.

The defendant seemed to choke up when the judge asked him if he was aware that being convicted of a felony waives his right to vote and serve on a jury. All eight counts are felonies. The judge noted that Cohen could serve up to 65 years in prison, though the prosecutors' recommended sentence is 46 to 63 months.

The plea deal does not include a written provision that he must cooperate as a witness in federal investigations, according to one source.

One moment of levity during the proceedings was when Cohen mentioned he had "one glass of Glenlivet 12" scotch the previous evening. The admission came in response to standard questioning by Judge William Pauley, who asked if Cohen had consumed any drugs or alcohol in the past 24 hours.

Cohen's attorney, Lanny Davis, said in a statement that Cohen made the plea so "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," said Davis. "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 told MSNBC's Rachel Maddow on Tuesday night that Cohen "has knowledge on certain subjects that should be of interest to the special counsel and is more than happy to tell the special counsel all that he knows, not just about the obvious possibility of a conspiracy to collude and corrupt the American Democracy system in the 2016 election ... but also knowledge about the computer crime of hacking and whether or not Mr. Trump knew ahead of time about that crime and even cheered it on."

Rudolph Giuliani, a lawyer for Trump, said, "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.”

In a statement, Stormy Daniels told NBC News, "Michael [Avenatti, her lawyer] and I are vindicated and we look forward to the apologies from the people who claimed we were wrong."

The charges stem from a probe of Cohen that is being led by the office of the U.S. Attorney for the Southern District of New York, which is working with the FBI and the IRS.

“This investigation uncovered crimes of fraud, deception and evasion, conducted through a string of financial transactions that were carefully constructed and concealed to protect a variety of interests," FBI Assistant Director-in-Charge William F. Sweeney Jr. said in a statement released by the Justice Department. "But as we all know, the truth can only remain hidden for so long before the FBI brings it to light. We are all expected to follow the rule of law, and the public expects us — the FBI — to enforce the law equally. Today, Mr. Cohen has been reminded of this important lesson, as he acknowledged with his guilty plea."

"[W]e should not expect law abiding citizens to foot the bill for those who circumvent the system to evade paying their fair share," added IRS Special Agent-in-Charge James D. Robnett.

Cohen, who once bragged he'd take a bullet for Trump, hinted in July that may have changed. "I put family and country first," he told ABC News last month.

Republican presidential nominee Donald Trump listens as his personal attorney Michael Cohen delivers remarks on his behalf during a campaign stop at the New Spirit Revival Center church in Cleveland Heights, Ohio, U.S. September 21, 2016. Jonathan Ernst / Reuters file

In addition to bank and tax fraud questions arising from Cohen's taxi business, federal prosecutors are looking into whether the hush-money payments Cohen arranged with women who claimed they had sexual encounters with Trump amount to violations of campaign finance law.

FBI agents raided Cohen’s office and hotel room in April and seized documents and electronics. According to people with knowledge of the search warrant, agents were looking for information related to the $130,000 transaction between Cohen and Daniels, as well as information about the payment of $150,000 to McDougal, and information about the "Access Hollywood" tape in which Trump was heard making vulgar boasts about women.

The FBI has also monitored his phone calls with a pen register, meaning that the incoming and outgoing phone numbers were recorded but not the content of the calls.

In July, Davis released a phone conversation that Cohen secretly recorded in which Trump mentions "cash" in relation to a possible payment involving McDougal.

Made two months before the presidential election, the tape appears to show Cohen, who was Trump's personal attorney at the time, discussing "how to set the whole thing up with funding." At one point, Trump appears to ask "what financing?" and seems to ask "pay with cash?"

Cohen appears to then say "No, no, no, no, no, no, I got ..." before Trump is heard saying, or asking, "check," and then the recording abruptly ends. Although the exact wording on the tape is unclear at times, it does make it clear that Trump was aware of the model's allegation of the affair and the plans to pay to ensure her silence.

Several major companies say Cohen contacted them after Trump’s upset victory in the 2016 president election promising access to the new administration. An official with the pharmaceutical company Novartis said the company signed a one-year, $1.2 million contract with Cohen, and AT&T also said it has met with Cohen. AT&T confirmed in an email to employees saying it had hired "several consultants" in early 2017 to help it "understand" the incoming administration.

Both Novartis and AT&T said they had been contacted by Mueller’s investigators.

Cohen, 51, was a vice president of the Trump Organization when he left the company in May. A former personal injury lawyer, he began working for the company in 2007 after helping Trump win a fight with the board at his condominium tower near the United Nations. He also owns numerous taxi medallions, which allow drivers to operate yellow cabs in New York.

He became known for taking aggressive action to defend Trump’s interests.