President Trump’s former personal attorney Michael Cohen pleaded guilty Thursday in New York to lying to Congress about a Moscow real estate project that Trump and his company pursued at the same time he was securing the GOP nomination in 2016.

In a nine-page filing, prosecutors laid out a litany of lies that Cohen admitted he told lawmakers in Congress about the Moscow project — an attempt, Cohen said, to minimize links between the proposed development and Trump as his presidential bid was gaining steam.

Cohen made a surprise appearance Thursday morning before U.S. District Judge Andrew L. Carter Jr., who asked him to enter his plea.

“Guilty, your honor,” Cohen replied. As part of the plea, Cohen said he had lied for the person listed in court documents as “Individual 1” — whom Cohen identified in court as Trump.

“I was aware of Individual 1’s repeated disavowals of commercial and political ties between himself and Russia, his repeated statements that investigations of such ties were politically motivated and without evidence, and that any contact with Russian nationals by Individual 1’s campaign or the Trump Organization had all terminated before the Iowa Caucus, which was on February 1 of 2016,” Cohen told the judge.

To hew closely to Trump’s public denials of such connections, Cohen said he knowingly gave false answers in 2017 to the Senate and House intelligence committees.

“I made these misstatements to be consistent with Individual 1’s political messaging and out of loyalty to Individual 1,” he told the packed courtroom in Lower Manhattan.

Cohen’s guilty plea — his second in four months — is the latest development in a wide-ranging ­investigation by special counsel Robert S. Mueller III into Russian interference in the 2016 presidential election. Activity in that probe has intensified this week, as one planned guilty plea was derailed and, separately, prosecutors accused Trump’s former campaign chairman Paul Manafort of lying to them since he pleaded guilty.

The Cohen plea is likely to further chill relations between the White House and the Justice Department, where acting attorney general Matthew G. Whitaker has been serving for several weeks since the president forced Jeff Sessions out of the post of attorney general.

Justice Department policies and special counsel regulations call for the attorney general to be notified of significant events in such investigations, and a person familiar with the case said Whitaker was notified ahead of time about Cohen’s plea.

As part of the plea, Cohen admitted to falsely claiming that efforts to build a Trump-branded tower in Moscow ended in January 2016, when in fact discussions continued through June of that year, the filing said. That was a critical period in the presidential campaign, when Trump was plowing past a crowded GOP field of candidates to win the nomination. Among those Cohen briefed on the project’s status was Trump, on more than three occasions, according to the document.

Trump has repeatedly said he had no business dealings in Russia, tweeting in July 2016, “For the record, I have ZERO investments in Russia,” and telling reporters in January 2017 that he had no deals there because he had “stayed away.”

After the plea, Trump told reporters at the White House that Cohen was “a weak person” and insisted that he himself had done nothing wrong.

“Michael Cohen is lying and he’s trying to get a reduced sentence for things that have nothing to do with me,” the president said. “This was a project that we didn’t do, I didn’t do. . . . There would be nothing wrong if I did do it.”

Talking about 2016, Trump added: “There was a good chance that I wouldn’t have won, in which case I would have gone back into the business, and why should I lose lots of opportunities?”

“It is hardly coincidental that the special counsel once again files a charge just as the president is leaving for a meeting with world leaders at the G20 Summit in Argentina,” Giuliani said in a statement, noting that Mueller also unsealed charges before the president left the country for a summit in Helsinki in July.

Rep. Adam B. Schiff (Calif.), the House Intelligence Committee’s senior Democrat, said the guilty plea shows the president was not truthful about his business interests in Russia during the campaign.

During the campaign, Cohen acted as Trump’s point person in talks aimed at building the Trump development in Moscow. Cohen has said the project was in its early stages in fall 2015, as Trump’s presidential campaign was heating up.

Cohen previously said the project stalled in January 2016, prompting him to email a top aide to Russian President Vladi­mir Putin seeking help. Cohen had previously claimed that he never received a response and that the project was halted that month.

In fact, according to Thursday’s court filing, the Russians did respond, and Cohen discussed the project for 20 minutes on the phone with an assistant to Dmitry Peskov, a senior aide to Putin. At the time, Cohen was seeking help securing land and financing.

Peskov did not respond Thursday to a request for comment.

Prosecutors seemed to make a point in the document of emphasizing that Cohen had talked with Trump — whom they did not name — about the project. The document said Cohen lied because he hoped his testimony would limit the ongoing Russia investigations.

Prosecutors also said that Cohen continued to have contact into summer 2016 with Felix Sater, a Russian-born developer assisting with the project. Some of those contacts were first reported by The Washington Post.

In June 2016, Sater invited Cohen to attend an economic conference in St. Petersburg, assuring Cohen that he could be introduced to Russian Prime Minister Dmitry Medvedev, top financial leaders and perhaps Putin, The Post reported.Sater has been cooperating with the special counsel investigation for more than a year, providing emails and other documents, people familiar with the probe have said.

In an interview with The Post on Thursday, Sater did not contest the details in the court filing and said he was surprised by Cohen’s plea, saying he had no prior warning it was coming.

According to the criminal information filed by prosecutors, Cohen sent a letter to the Senate Intelligence Committee in which he “knowingly and deliberately” made false statements, including that the Moscow project “ended in January 2016 and was not discussed extensively with others in the company”; that Cohen “never agreed to travel to Russia in connection with the Moscow project and ‘never considered’ asking Individual 1 to travel for the project”; and that Cohen “did not recall any Russian government response or contact about the Moscow Project.”

Cohen had claimed to the committee that he had discussed the project with Trump only three times and that all discussions ended in January 2016. In fact, according to the court filing, discussions continued well into 2016, and Cohen spoke more than three times with Trump about the project and also briefed members of Trump’s family.

The document also says Cohen discussed in May 2016 the possibility that he might travel to Russia before the Republican National Convention and that Individual 1 might travel there after the convention.

Then, about a month later, he met “Individual 2” — whom people familiar with the case said was Sater — in the lobby of Trump corporate headquarters to tell Sater he would not be traveling to Russia after all, according to the court document. The day of that meeting — June 14, 2016 — is the same day The Post reported that Russian government hackers had stolen data from the Democratic National Committee.

Federal sentencing guidelines would call for Cohen to face a prison sentence of six months at the high end and no time in prison at the low end for making false statements, according to his plea agreement. Both sides agreed that they would not ask for a sentence outside that range, provided Cohen continues to cooperate.

Outside the courthouse Thursday, Guy Petrillo, an attorney for Cohen, said: “Mr. Cohen has cooperated. Mr. Cohen will continue to cooperate.” Petrillo said sentencing in the case is set for Dec. 12.

Cohen said nothing as reporters shouted questions at him.

In August, Cohen, 52, pleaded guilty to campaign finance violations related to payments before the election to two women who alleged that they had affairs with Trump years earlier. He told the court that he had arranged those payments at Trump’s direction and that they were intended to keep the women quiet before the presidential vote.

He had also pleaded guilty to multiple counts of tax evasion, as well as bank fraud, related to his personal finances and management of New York taxi medallions.

Cohen worked as a top attorney to Trump and his real estate company for a decade. After Trump took office, Cohen left the company and became a personal attorney to the president, while taking on consulting clients, including AT&T, Novartis and a New York firm that manages assets for a Russian billionaire.

Once one of Trump’s most loyal aides, he has made a thorough turn against the president in recent months. Cohen used to describe himself as Trump’s pit bull and delighted in jousting with the celebrity business executive’s enemies, once asserting that he would “take a bullet” for his longtime boss.

But after pleading guilty, he said his conscience required him to tell the truth about Trump. Before the midterm elections, he urged the public to vote for Democrats, writing on Twitter that the midterms “might be the most important vote in our lifetime.”

In recent months, he has been spending hours meeting with prosecutors, including Mueller’s team, and was spotted recently arriving in Washington for additional meetings with his legal team.

John Wagner and Tom Hamburger in Washington and Anton Troianovski in Moscow contributed to this report.