Michael Cohen pleaded guilty Tuesday to violating campaign finance law with pre-election payoffs to women and said he did so “at the direction” of President Donald Trump.

The deal that federal prosecutors in Manhattan struck with Cohen—Trump's former personal attorney and once-loyal fixer—does not require him to testify against anyone.

But Cohen's own attorney, Lanny Davis, suggested that he is open to cooperating with Special Counsel Robert Mueller, who is investigating Russian meddling in the election and any collusion by the Trump campaign.

“Mr. 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,” attorney Lanny Davis told MSNBC's Rachel Maddow.

In the New York case, Cohen pleaded guilty to eight federal counts: five counts of tax evasion, one count of making a false statement to a financial institution, one count of causing an unlawful corporate contribution, and one count of making an excessive campaign contribution..

His plea agreement with the U.S. Attorney's Office calls for a sentencing range of 43 to 63 months, far less than the 65 years he could have faced if he were convicted at trial. But the judge is not bound by the agreement and can theoretically give Cohen more or less time when he is sentenced on Dec. 12.

Freed pending the posting of a $500,000 bond, Cohen left the Manhattan courthouse to chants of "Lock him up!" from onlookers.

In a tweet several hours later, Davis, suggested that prosecutors should charge Trump based on Cohen's admissions.

Cohen's plea hearing began about two hours after he surrendered at FBI headquarters in New York—and in a surreal coincidence, as former Trump campaign chairman Paul Manafort was being convicted of unrelated fraud charges in Virginia.

Cohen walked into a lower Manhattan courtroom not handcuffed, wearing a yellow tie, white shirt, and dark suit. Prosecutors were seated at a table, waiting for him to arrive.

When asked “how are you?” Cohen nodded with a dour expression. He let out a loud sigh as he reviewed and signed paperwork and stood attentively with his hands crossed as Judge William Pauley advised him of his rights. Pauley grilled Cohen on his competence and asked whether he had drugs or alcohol in the past 24 hours.

“Yes, your honor. Last night at dinner I had a glass of Glenlivet 12 on the rocks,” he said to some laughter.

Then came the serious business of admitting to his crimes, which included failing to report $4 million in income, including $1.3 million from his ownership of valuable taxi medallions, and $14 million in debt from a bank.

When he pleaded to the two counts related to campaign-finance law, Cohen implicated Trump without identifying him by name.

Cohen said he paid off a women “in coordination with and at the direction of a candidate for federal office” and that he worked with “the CEO of a media company” to keep that individual from publishing and disclosing damaging information on the candidate. Cohen said he arranged the company to pay the woman $150,000.

Ex-Playboy model Karen McDougal said she dated Trump throughout 2006 and 2007. According to McDougal, she sold her life rights to American Media, Inc., which owns the National Enquirer, in 2016. AMI never published McDougal’s story of an affair with Trump, a practice known as “catch and kill.”

AMI’s CEO is David Pecker, a personal friend of Trump.

The other count apparently concerned Stormy Daniels, the adult-film actress who claims she had an affair with Trump in 2006. Prosecutors said in court papers that the National Enquirer also played a key role in silencing Daniels.

Cohen said “in coordination with and at the direction of the same candidate, I arranged to make a payment to a second individual” by using a company he controlled. Daniels was paid $130,000 from Cohen’s LLC in October 2016 in exchange for her signing a non-disclosure agreement to keep secret allegations against Trump.

“The monies I advanced through my company were later repaid to me by the candidate,” Cohen said in court.

In court papers, Cohen invoiced executives of the Trump Corporation under the guise of a retainer agreement. “In truth and in fact, there was no such retainer agreement,” prosecutors said.

Both women previously filed lawsuits asking to be released from these contracts. McDougal has settled and stepped out of the spotlight, but Daniels’ case is on hold pending the outcome of the Cohen probe.

"Michael [Avenatti] and I are vindicated and we look forward to the apologies from the people who claimed we were wrong,” Daniels said in a statement following Cohen’s guilty plea, referring to her attorney, who has been predicting Cohen would go to jail for months.

Cohen’s claims about payoffs to the women stand in opposition to a year’s worth of denials from Trump and his lawyers that the then-candidate did not know in advance Cohen sought to quiet damaging allegations with money during an election year.

Deputy U.S. Attorney Robert Khuzami said in a press conference following the proceeding that the payments were “for the purpose of influencing the 2016 election.”

The downfall of Trump’s longtime lawyer was set in motion April 9 by an FBI raid on his home, office and hotel room. The raid was reportedly authorized by Deputy Attorney General Rod Rosenstein, a target of Trump’s frequent ire over the Russia investigation.

The U.S. Attorney’s Office for the Southern District of New York said in court filings at the time that it was investigating “Cohen’s personal business dealings and finances.” Prosecutors eyed Cohen for months, reportedly over possible bank fraud, wire fraud and campaign-finance violations.

Search warrants reportedly sought information on $20 million in loans Cohen took out from two banks that deal with the taxi industry, which Cohen was a part of through his ownership of medallions that authorize cabs in New York.

The warrants also sought information on Cohen’s role in muzzling at least two women who allegedly had extramarital affairs with Trump: Stormy Daniels, who claimed she bedded the now-president at a Lake Tahoe golf tournament in 2006, and ex-Playboy model Karen McDougal, who said she dated Trump throughout 2006 and 2007.

Daniels signed a nondisclosure agreement with Trump and Cohen days before the election in exchange for $130,000, while McDougal’s story was bought, then buried, by the Trump-friendly publisher of the National Enquirer. Both women filed lawsuits asking to be released from these contracts. McDougal has settled and stepped out of the spotlight, but Daniels’ case is on hold pending the outcome of the Cohen probe.

Avenatti celebrated Cohen’s imminent guilty plea on Twitter.

Hours after the FBI came knocking, President Trump called the raid a “disgraceful situation” and “an attack on our country.” Cohen was famously Trump’s most-dependable bulldog, saying he would “do anything” to protect him, even to “take a bullet.”

Weeks after the raid though, their relationship — said to have been frosty since Trump became president and reportedly spurned Cohen for a West Wing job — turned to ice.

In June, CNN reported Cohen claimed that Trump has prior knowledge of the infamous Trump Tower meeting with Russians offering “dirt” on Hillary Clinton. In response, Trump attorney Rudy Giuliani said Cohen had “lied all his life.”

Days later, in Cohen’s first and only interview since the raid, Trump’s former fixer said his family “have my first loyalty and always will.”

“I put family and country first,” he told Good Morning America ’s George Stephanopoulos.

Days after the FBI search, Cohen, 52, lawyered up and sought a temporary restraining order in Manhattan federal court, asking that his legal team inspect the materials for attorney-client privilege before handing them to prosecutors.

On April 26, U.S. District judge Kimba Wood appointed a former colleague, Barbara Jones, as the “special master,” or independent party, tasked with reviewing the seized paper and electronic items for privilege.

Federal agents confiscated over 3.7 million files, and a review of the documents came to an end on Monday. Judge Wood on Tuesday accepted Jones’ finding that “7,146 of those items are privileged, eight are partially privileged, and 285 are highly personal.” None of those items may be supplied to the government as part of its investigation, Wood ruled.

After the raid, Cohen then hired two new lawyers, one to deal with feds and one to deal with Trump: Guy Petrillo, former chief of SDNY’s criminal division and an experienced trial lawyer; Lanny Davis, a lawyer “best known as a high-profile spinner for Bill and Hillary Clinton,” as The New York Times put it.

Davis took on Trump’s own lawyer, Giuliani, in a fight that played out on TV in July.

That month, Davis released one of several tapes Cohen is said to have made of Trump when they two worked together at the Trump organization. On the tape, Trump and Cohen apparently discuss how to pay off McDougal.

"I need to open up a company for the transfer of all of that info regarding our friend David," Cohen said, likely referencing AMI owner David Pecker. When Cohen tells Trump about financing, Trump said “pay with cash.”

Giuliani said Trump never paid any money towards the McDougal catch and kill.

Prosecutors have 12 audio tapes made by Cohen, CNN reported last month.