Former Trump campaign official Rick Gates, left, and former Trump campaign chairman Paul Manafort are accused of defrauding the IRS and lying to U.S. banks to obtain loans. (Brendan Smialowski/AFP/Getty Images)

As Donald Trump crisscrossed the nation promising to drain the swamp, two of his top advisers were busy illegally building a colossal fortress of riches deep inside that swamp, according to federal prosecutors.

For a decade prior and on through Trump’s populist crusade, Paul Manafort and Rick Gates used offshore accounts, hidden income, falsified documents and laundered cash to maintain Manafort’s lush life of multiple homes, fine art, exquisite clothes and exotic travel, the government says.

In a richly detailed expanded indictment filed Thursday, special counsel Robert S. Mueller III parted the curtain shielding how two longtime Washington influence merchants worked the system. The government contends that Manafort, who was Trump’s campaign chairman for five months before being fired, used people all around him, from his buddy Gates to banks, clients and the IRS, to build a life of conspicuous consumption.

Gates, who was Manafort’s deputy in their lobbying firm and on the Trump campaign, pleaded guilty Friday to conspiracy and lying to the FBI, cutting a deal with prosecutors to give them information that could help Mueller’s investigation into Russian interference in the 2016 presidential election.

Manafort, meanwhile, has maintained his innocence. His spokesman, Jason Maloni, said that Manafort is “confident that he will be acquitted and violations of his constitutional rights will be remedied.”

An attorney for Gates declined to comment on Thursday’s indictment.

If convicted, Manafort faces punishment that could put him behind bars for the rest of his life.

But for the years when he was working for Ukrainian leader Viktor Yanukovych, the money poured in by the millions.

From 2006 on, much of it came from Manafort and Gates’s prized client, Yanukovych, and his Party of Regions, which paid their firm $17 million between 2012 and 2014, according to federal filings.

Even after the money stopped flowing, Manafort and Gates found ways — illegal ways, prosecutors say — to maintain and even improve their lifestyles.

After Ukrainians took to the streets in 2014 in an uprising against their government’s corruption, and Yanukovych fled to the protection of his close ally, Russian President Vladi­mir Putin, Manafort and Gates misled banks and borrowed millions, allowing Manafort to live in bigger and better houses, buy fabulous fashions and expand an already impressive collection of antique rugs, prosecutors allege.

With extensive help from Gates, Manafort opened a gusher of spending on personal pleasures, according to the indictment prosecutors filed this week. (Outwardly, Gates, who is 45, lived more modestly, but he, too, had amassed quite a fortune. Although he listed $2.2 million in assets in a court document in 2011, he wrote in a credit application in 2016 that he was worth $25 million and that his wife had assets of $30 million, the indictment says.)

Manafort, a longtime mainstay of Washington politics who tracked delegates for President Gerald Ford’s 1976 campaign and ran Ronald Reagan’s campaign in the South in 1980, and Gates had spent two decades at the pinnacle of Washington’s influence industry, collecting clients such as the Ukrainian leader and other strongmen from Congo, the Philippines and other countries who depended on the duo to advance their interests.

Manafort, 68, was not shy about displaying the fruits of that work.

The money went, the government says, to home contractors, with $5.4 million going to one on the East End of Long Island, where Manafort had a lavish 10-bedroom spread in tony Bridgehampton. (Manafort has since put that property — along with three others in Manhattan, Palm Beach and Alexandria — up as collateral in his $12 million bail deal with the government.)

Prosecutors say that Manafort made monthly payments to the home improvement company, many of them in six-figure amounts, drawn from accounts that he and Gates controlled in Cyprus and the Grenadines, companies with names such as Global Highway Limited and Lucicle Consultants.

Another $655,000 allegedly went to a Hamptons landscaper over a 2½ -year period. A second landscaper got $165,000 over the following two years.

The indictment describes how money poured into the coffers of the businesses that could turn a house into a state-of-the-art entertainment complex. It alleges that a lighting and home entertainment company in Florida got $1.3 million from five Manafort-controlled entities. Over two years, an antique-rug shop in Alexandria collected $934,000 from Manafort’s Cypriot accounts, prosecutors say.

Manafort spent $849,000 at one men’s clothing shop in New York City in 34 visits over six years — an average of $25,000 per shopping venture. Another clothing store, in Beverly Hills, collected $520,000 from Manafort on nine dates over five years, about $58,000 per visit.

Manafort allegedly bought Range Rovers (four of them in five years), a Mercedes, art, ­audio-video systems, a condo, a Manhattan brownstone and his Alexandria house.

He liked to live large and he didn’t mind if others saw how he spent his wealth. He once testified before Congress that although “the technical term for what we do . . . is ‘lobbying’ . . . I will admit that, in a narrow sense, some people might term it ‘influence peddling.’ ”

His friends loved that chesty bravado of his, and some of them called him “the Count of Monte Cristo,” named for the swashbuckling hero of the 19th-century French novel.

But prosecutors describe how much of Manafort’s fortune was not flaunted: Millions were tucked away in an extensive network of foreign companies and bank accounts in Cyprus, the Grenadines and the Seychelles islands. In the lean years that followed the flight of their Ukrainian patron, Manafort and Gates allegedly tapped into their foreign holdings, bringing large sums back home and presenting those transactions not as repatriated assets but as new income — thereby persuading banks to lend them more than $20 million that, prosecutors argue, they otherwise would not have qualified for.

The financial misdeeds that Manafort and Gates have now been accused of have nothing to do with their work for the Trump campaign. Mueller is apparently engaged in a classic prosecutor’s methodology, identifying other crimes committed by people in the orbit of the main subject of the investigation, and then using that evidence to find out if those people have incriminating information about the person prosecutors are really interested in.

On its face, the indictment filed Thursday is a fairly simple case of alleged tax fraud. A federal law called the Bank Secrecy Act says that if you have accounts in foreign banks — whether the accounts are in your name — you must report them to the U.S. Treasury.

The IRS’s 1040 tax form asks, “Did you have an interest in or a signature or other authority over a financial account in a foreign country?” Year after year — all the way up to last October — Manafort and Gates repeatedly answered, “No,” when, in fact, the government says, they had extensive foreign interests.

During the fat years when Yanukovych was on the rise and then in power, Manafort and Gates were able to stockpile millions in those foreign entities, prosecutors say. After 2014, when the cascade of money dried up, Manafort and Gates adapted.

Using the real estate Manafort had acquired with their Ukrainian fees as collateral, he — allegedly with Gates’s assistance — took out millions of dollars in mortgages. To get the mortgages, the government contends, Manafort and Gates concocted fake profit and loss statements that inflated their income.

In 2012, Manafort bought a four-story, 19th-century brownstone rowhouse in the Carroll Gardens section of Brooklyn. He paid $3 million in cash — from one of the men’s Cyprus accounts, prosecutors say — for the place on Union Street and set about renovating it from the guts out. The house already had marble mantelpieces and a Jacuzzi, but Manafort took it to a new level, adding a two-story extension out back, new windows, a roof deck and a slate walkway.

Neither Manafort nor his daughter ever moved in. The daughter, according to the New York Times, told neighbors that she loved the place and intended to live in it. As the renovations continued, Manafort took out a $5 million loan, supposedly to pay for the rehabilitation of the house. But Manafort, the government says, actually had no such intention. “The construction mortgage will allow me to pay back [another Manafort apartment] mortgage in full,” he wrote to his tax preparer in December 2015.

Similarly, Manafort in 2012 bought a $2.85 million condo in Manhattan’s pricey Soho neighborhood — also with cash, also from the accounts in Cyprus, the indictment says. For more than two years, he rented the place out on Airbnb, charging several thousand dollars a week, prosecutors say.

At the same time as he was renting out the apartment, Manafort sought a $3.4 million mortgage on it. To get a loan that large, the bank wanted to see that the condo was occupied by its owner. That’s exactly what Manafort claimed was the case, the government says.

“In order to have the maximum benefit, I am claiming Howard St. as a second home,” Manafort wrote in an email cited by prosecutors. “Not an investment property.”

The email was written in January 2016 — smack in the middle of the period when Manafort was renting out the place on Airbnb.

He told the lender that his daughter and son-in-law were using the condo and that it was not a rental property. And Manafort wrote to his son-in-law to remind him that when the bank’s appraiser showed up to assess the condo, he should “remember, he believes that you and [Manafort’s daughter] are living there.”

But the bank got suspicious, discovering that there was, indeed, a mortgage on Manafort’s Brooklyn brownstone, even though Manafort had written on his loan application that he owned the Brooklyn place free and clear.

Gates responded, prosecutors say, by having an insurance broker send the bank an old insurance report that listed no mortgage on the Union Street rowhouse. Gates emailed Manafort to let him know how he had handled the situation, the indictment says. Within hours, Manafort replied: “good job on the insurance issues.”

Still, it wasn’t clear that the lender was going to approve the loan on the Howard Street condo. There was another problem: A tax return that Manafort included in his application showed that he had received a $1.5 million loan from one of the entities in Cyprus that he and Gates controlled. With that large a debt on Manafort’s record, the bank was hesitant to approve a new loan.

In fact, the government alleges, there never was any loan; the money had just been transferred from Cyprus to the United States, but it had been called a loan so Manafort wouldn’t have to pay taxes on the income.

But now the “loan” was causing a problem, so, prosecutors say, Manafort and Gates had a tax accountant send the lender backdated documents falsely stating that the $1.5 million loan had been forgiven in 2015.

In March 2016, Manafort got a $3.4 million mortgage on the Howard Street condo.

About that same time, Manafort applied to borrow yet more money, this time a business loan. To boost the application’s prospects, prosecutors say, Gates asked a bookkeeper to add $2.4 million to the stated income of their company. “Can you make adjustments on your end and then just send me a new scanned version?” Gates asked in an email.

The bookkeeper refused, the government says, so Gates did it himself. “I am editing Paul’s 2015 P&L statement,” he wrote, sending the altered profit and loss statement to the lender. The loan application claimed that the company Manafort and Gates controlled had $4.45 million in net income; prosecutors say the real income was less than $400,000.

To win approval of the loans, the men needed help from inside the banks. They found what prosecutors call “a conspirator” who worked for one of the lenders. When Manafort and Gates’s loan application first arrived, the lender’s employee wrote back, “Looks Dr’d. Can’t someone just do a clean excel doc and pdf to me??”

The final, successful application included a later and different version of the paperwork.

But sometimes the duo’s methods didn’t work. In 2016, when Manafort applied for a mortgage on his Bridgehampton house, he told the bank that his firm would be getting $2.4 million in income later that year for work on a “democratic development consulting project.”

To back up that claim, the government says, Gates gave the bank a fake invoice for $2.4 million, attesting that the payment was for “services rendered per the consultancy agreement pertaining to the parliamentary elections.”

But the bank wanted more proof that Manafort had sufficient income to be able to pay back a loan. When it wasn’t forthcoming, the bank rejected the application, according to the indictment.

Undeterred, Manafort and Gates applied to a different bank, using what prosecutors say were false and doctored financial documents to overstate their firm’s income by millions.

In October 2016, Manafort emailed Gates a PDF version of their firm’s actual profit and loss report, showing that they’d lost more than $600,000. Gates then allegedly converted the PDF into a Word document so it could be edited. He sent that back to Manafort, who then added more than $3.5 million in income to the document and returned it to Gates, who converted it back to a PDF that was sent to the bank.

Still, the bank had another problem with the application: Manafort owed American Express $300,000, and the debt had damaged his credit rating. So Manafort replied that he had actually lent his credit card to Gates, who had spent the money and failed to reimburse his partner. Manafort sent the bank a letter from Gates, who said that he had incurred the Amex charges and would pay his partner back.

The result, the government says: two loans worth $16 million.