ALEXANDRIA, Va. -- Paul Manafort's protege wrapped up his testimony Wednesday after implicating the former Trump campaign chairman and himself in financial crimes while also enduring stinging attacks on his character and credibility.

Rick Gates has been the government's star witness in Manafort's financial fraud trial, testifying how, at the behest of his longtime boss, he helped conceal millions of dollars in foreign income and submitted fake mortgage and tax documents.

Defence lawyers saw an opening to undermine his testimony by painting him as liar and a philanderer, getting him to admit to an extramarital affair and reminding jurors how he had lied to special counsel Robert Mueller's team while working out a plea deal for himself.

The testimony, stretching across three days, created an extraordinary courtroom showdown between the two former Trump campaign aides who were indicted together by Mueller but who have since opted for radically different strategies: Manafort is the lone American charged by Mueller to opt for trial, whereas Gates pleaded guilty and agreed to co-operate by testifying against his former boss.

Neither man was charged in connection with their Trump campaign work, but the trial has nonetheless been a distraction for a president who insists Manafort was treated shabbily and who continues to publicly fume about Mueller's investigation into potential ties between his associates and the Kremlin.

Prosecutors sandwiched the testimony of Gates around other witnesses who, in sometimes dry and detailed testimony, described Manafort's lavish spending and use of offshore accounts to stash Ukrainian political consulting fees.

A clothier said he sold Manafort more than $900,000 in luxury clothes, a bookkeeper says she helped disguise foreign income as a loan to reduce Manafort's tax burden and, on Wednesday, an FBI forensic accounting specialist said Manafort hid more than 30 offshore accounts in three types of currencies from the IRS.

Overall, the accountant traced more than $65 million flowing into offshore accounts controlled by Manafort, and she detailed for jurors how more than $15.5 million flowed out to fund his lavish lifestyle between 2010 and 2014.

But it was Gates' testimony that has so far generated the most drama, as the witness admitted embezzling hundreds of thousands of dollars from his boss, confessed to an extramarital affair and turned in spectacular fashion against a longtime mentor.

Prosecutors relied on Gates to provide direct, first-hand support of the accusations against Manafort.

He told jurors how he disguised millions of dollars in foreign income as loans in order to lower Manafort's tax bill. He recounted how he and Manafort used more than a dozen offshore shell companies and bank accounts in Cyprus to funnel the money, all while concealing the accounts and the income from the IRS.

Prosecutors sought to soften the blow of the cross-examination by asking Gates to acknowledge his own crimes, including a lie to Mueller's team in February. But Gates nonetheless faced aggressive questioning by Manafort's lawyer, Kevin Downing, who at one point asked him, "After all the lies you've told and the fraud you've committed, you expect this jury to believe you?"

Downing made one last effort Wednesday to erode Gates' credibility as he tried to confront him over whether he had engaged in four extramarital affairs, instead of just the one that he had admitted to earlier in the trial.

But after a lengthy conference between lawyers, Downing asked Gates only about the time span of his "secret life."

Gates replied, "I made many mistakes over many years" before he stepped down from the witness stand.

Downing also sought to counter earlier testimony that Manafort had encouraged Gates to deceive authorities. He got Gates to acknowledge that Manafort told him to be truthful about offshore shell companies and bank accounts during a 2014 interview with the FBI.

The interview was part of an FBI investigation that sought to recover assets looted from the Ukrainian government under the rule of former President Viktor Yanukovych.

Gates said under questioning Wednesday that he told FBI agents and Justice Department lawyers about some of the offshore companies that contained millions of dollars in proceeds from their Ukrainian political work.

But prosecutor Greg Andres followed up by suggesting that Gates and Manafort were not fully truthful.

"Did you tell the FBI that there was hidden income in those accounts?" Andres asked.

"No, I did not," Gates responded.

Once Gates finished testifying, prosecutors resumed trying to make their case through documentary evidence to demonstrate Manafort's control of offshore bank accounts containing millions of dollars. None of those accounts were reported to the IRS as required by U.S. law.

An FBI forensic accountant, Morgan Magionos, told jurors bank records from Cyprus, St. Vincent and the Grenadines and the United Kingdom revealed the accounts were connected to Manafort and his associates. She said Manafort's passport was used to open many of them in U.S. dollars, euros and British pounds.

Using charts, emails and financial and tax records, Magionos told jurors how she traced millions of dollars of payments for mortgages, home improvements, rugs and clothes back to his hidden foreign bank accounts. In one case, she alleged that foreign accounts were used by Manafort to pay for more than $3.5 million in home improvements.

Konstantin Kilimnik, a man prosecutors say has ties to Russian intelligence, was also among the beneficial owners of some of the companies. Kilimnik is charged along with Manafort with witness tampering in a separate case. Gates was also listed as an owner of several of the accounts.

Also Wednesday, an IRS agent, Michael Welch, testified that Manafort didn't report at least $16 million on his tax returns between 2010 and 2014. He also said Manafort should have reported multiple foreign bank accounts to the IRS in those years.

U.S. District Judge T.S. Ellis III repeatedly has interrupted prosecutors to encourage them to speed things along. He poked fun at himself Wednesday as he haggled with attorneys over the number and type of charts prosecutors could present during the testimony of the accountant.

"Judges should be patient. They made a mistake when they confirmed me. I'm not very patient, so don't try my patience," Ellis said.

Prosecutors say they have eight witnesses left and expect to rest their case by Friday afternoon.

------

Associated Press writer Matthew Barakat contributed to this report.