– Paul Manafort agreed Friday to tell all he knows to special counsel Robert Mueller as part of a plea deal that could shape the final stages of the inquiry into Russian interference in the 2016 election.

The deal was a surrender by Manafort, President Donald Trump's former campaign chairman, who had vowed for months to prove his innocence in a case stemming from his work as a political consultant in Ukraine. And it was a decisive triumph for Mueller, who now has a cooperating witness who was at the center of the Trump campaign during a crucial period in 2016 and has detailed insight into another target of federal prosecutors, the network of lobbyists and influence brokers seeking to help foreign interests in Washington.

Manafort's decision, announced at a federal court hearing in Washington in which he pleaded guilty to two conspiracy charges, was a distinct setback for Trump, who had praised Manafort for standing up to prosecutors' pressure and had hinted that he might pardon him.

It is not clear what information Manafort offered prosecutors in the negotiations that led to the plea deal. But in court Friday, Manafort agreed to an open-ended arrangement that requires him to answer "fully, truthfully, completely and forthrightly" questions about "any and all matters" the government wants to ask about.

The president's personal lawyer, Rudy Giuliani, quickly sought to distance Trump from the plea deal.

"Once again an investigation has concluded with a plea having nothing to do with President Trump or the Trump campaign," he said in a statement. "The reason: The president did nothing wrong and Paul Manafort will tell the truth."

Mueller's investigation has maintained such secrecy that it is impossible to know what puzzle pieces he might still be trying to fill in or what Manafort's testimony might mean for Trump. But at a minimum, Manafort's cooperation gives Mueller additional visibility into some key moments in the campaign and the role of other senior figures.

Manafort was a participant in the June 2016 meeting at Trump Tower that had been arranged by a Moscow lawyer who said she was delivering damaging information about Hillary Clinton on the Kremlin's behalf. His cooperation could help Mueller establish how much, if anything, the Trump campaign knew about Russia's efforts to boost Trump's candidacy.

Manafort joins four other Trump aides who have offered cooperation in exchange for lesser charges in cases that Mueller's office either pursued or referred to federal prosecutors in New York. They include Michael Cohen, the president's longtime personal lawyer; Michael Flynn, the former national security adviser; Rick Gates, the former deputy campaign chairman; and George Papadopoulos, a former campaign adviser.

Manafort, 69, had insisted for a year that he would not assist the special counsel's office. But after being convicted on eight felony counts in a federal court in Virginia last month, and facing a second trial on more felony charges in federal court in Washington, Manafort was confronted with the very real prospect of spending the rest of his life in prison.

Under the agreement announced Friday, prosecutors replaced a seven-count indictment with one that charged two counts of conspiracy that carry a maximum penalty of 10 years behind bars. No sentencing date has been set for those charges or the ones he was convicted of in Virginia.

Manafort also agreed to surrender most of his once-vast personal fortune, including three houses and two apartments.

At the court hearing, Manafort, who has been in jail since June, appeared weary and subdued. He sat grim-mouthed, eyes cast downward, as Andrew Weissmann, the lead prosecutor on his case, read through what Judge Amy Berman Jackson of U.S. District Court called the longest recitation of offenses she had ever heard in her courtroom.

Kevin Downing, Manafort's lead lawyer, said it was a "tough day for Mr. Manafort but he has accepted responsibility" for criminal conduct that dates back "many years." He added, "He wanted to make sure his family was able to remain safe and live a good life."