President Trump’s former personal attorney Michael Cohen pleaded guilty to eight criminal counts Tuesday afternoon, including tax fraud, false statements to a bank and campaign finance violations — and indirectly said that he did so at the direction of the president.

Cohen pleaded guilty to five counts of tax evasion from 2012 to 2016, one count of making a false statement to a financial institution, one count of willful cause of unlawful corporate contribution and one count of excessive campaign contribution on Oct. 27, 2016.

[More: Trump's 'bad week': Manafort found guilty, Cohen enters plea deal]

Judge William H. Pauley III set a sentencing hearing of Dec. 12 for Cohen, who was released on $500,000 bond.

In federal court in Manhattan Tuesday, Cohen said that he kept the information about the alleged affairs quiet "in coordination and at the direction of a candidate for federal office" — a likely reference to his former boss, Donald Trump.

According to the charging document filed in the Southern District of New York by Acting U.S. Attorney Robert Khuzami, Cohen failed to report more than $4 million in income between 2012 and 2012, resulting in avoiding paying more than $1.4 million in taxes.

Payments arranged with two unnamed women — likely Stormy Daniels and Karen McDougal — who alleged affairs with Trump before he began his campaign for president are also central to the charges lodged against Cohen.

[Related: Stormy Daniels speaks out about Cohen guilty plea: Michael Avenatti and I are ‘vindicated’]

Both payments were made by Cohen within months of the 2016 presidential election.

According to the charging document, Cohen entered into an agreement with the chairman and CEO of “Corporation-1” (American Media, Inc.) which owned “Magazine-1” (the National Enquirer) to “help deal with negative stories about Individual-1’s relationships with women, by among other things, assisting the campaign in identifying such stories so they could be purchased and their publication avoided.”

The charging document makes it clear that “Individual-1” is Trump, as it says this person “began his presidential campaign” on June 16, 2015.

The agreement allowed for Cohen to “arrange for the purchase of two stories so as to suppress them and prevent them from influencing the election.”

Cohen, in his guilty plea, admitted he made an "unlawful corporate contribution" of $150,000.

McDougal was paid $150,000 by American Media Inc., in 2016 in order to keep her quiet about the affair in August 2016.

McDougal had begun an attempt to tell her story of her alleged affair beginning in June 2016, “knowing the story would be of considerable value because of the election,” the charging document alleges.

According to the charging document, American Media Inc. bought the “limited life rights” to the story of McDougal’s alleged affair for $150,000 and a “commitment to feature her on two magazine covers and publish over one hundred magazine articles authored by her.”

Cohen allegedly told the chairman of American Media Inc. that he would be reimbursed for the $150,000 payment, and said he understood the agreement to mean the story would be suppressed “so as to prevent it from influencing the election.”

Cohen then bought agreement between American Media Inc. and McDougal sometime between late August 2016 and September 2016 for $125,000.

Cohen, in his guilty plea, also admitted he made an "excessive campaign contribution" of $130,000.

On Oct. 8, 2016, the charging document reveals an agent for Daniels told an editor at the National Equirer that she was ready to go public with her story.

Cohen was contacted by American Media Inc.’s chairman and an editor at the National Enquirer about the potential story, and Cohen then reached out to the attorney representing Daniels.

Daniels then negotiated a $130,000 agreement with Daniels’ attorney to “purchase [her] silence” and received a “signed confidential settlement agreement.”

The deal was settled on Oct. 27, 2016. Since then, Daniels and her attorney, Michael Avenatti, have filed a lawsuit claiming the nondisclosure agreement she signed should be nullified because Trump himself didn’t sign it.

The charging document alleges that Cohen “caused and made the payments described herein in order to influence the 2016 presidential election.”

“In doing so, he coordinated with one or more members of the [Trump] campaign, including through meetings and phone calls, about the fact, nature, and timing of the payments," the charging document alleges.

Because of Cohen’s payments, says the document, neither McDougal or Daniels “spoke to the press prior to the election.”

Cohen allegedly does not have to comply with federal authorities as part of the deal.

Cohen’s home, office, hotel, safety deposit box, and electronic devices were raided by the FBI in April, where agents seized 4 million items.

A review of the items seized has been completed as of Tuesday.

A special master was appointed by U.S. District Judge Kimba Wood earlier this year to review the 4 million items seized to determine attorney-client privilege.

An order signed by Wood on Monday and made public Tuesday reveals she agrees that 7,146 items reviewed fall under attorney-client privilege.

Rudy Giuliani, the president’s new attorney, revealed in May that Trump had reimbursed Cohen for the payment. Giuliani also said that Trump “didn’t know about the specifics of it but he did know about the general arrangement, that Michael [Cohen] would take care of things like this.”

That revelation was a contradiction to a statement Trump made in April that he did not know about the payment.

In a statement Tuesday, Giuliani said the charges do not show any allegation of “wrongdoing against” Trump.

“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.”