Jeffrey E. Thompson on Monday pleaded guilty in federal court to funding a “shadow campaign” to help Vincent C. Gray win the 2010 mayoral election. (Evelyn Hockstein/For The Washington Post)

Mayor Vincent C. Gray had detailed knowledge about an illegal fundraising operation that helped him capture the 2010 election and personally asked a prominent D.C. business executive to finance the scheme, prosecutors said Monday.

At a court hearing likely to roil the current mayoral race, prosecutors for the first time alleged that Gray (D) knew about businessman Jeffrey E. Thompson’s conspiracy to pump more than $660,000 in illegal donations into the campaign.

In fact, prosecutors said, Gray and the businessman devised a plan in which Gray would refer to Thompson as “Uncle Earl” to conceal his identity. At one point, Gray gave Thompson a one-page, $425,000 budget request that the businessman then funded, according to the plea agreement.

The new details about the mayor’s purported involvement emerged at a hearing in which Thompson pleaded guilty to funneling more than $2 million in illegal donations to federal and local campaigns over a six-year period.

“Jeff Thompson’s guilty plea pulls back the curtain to expose widespread corruption,” U.S. Attorney Ronald C. Machen Jr. said at a news conference after the hearing. “His plea gives the citizens of D.C. an inside look at the underground, off-the-books schemes that have corrupted election after election, year after year.”

Machen said that investigators would “hold accountable all of those who conspired . . . to withhold the truth from the public” and urged Thompson’s collaborators to “come forward and own up to your conduct.”

Gray, who has long denied wrongdoing, invited reporters to his office Monday and accused Thompson of lying. He vowed to serve out his term and continue campaigning for reelection ahead of the April 1 Democratic primary.

“It’s shocking to me,” Gray said, his voice measured during an interview. “Lies. These are lies.”

Thompson, the mayor said, was seeking to implicate him in order to reduce his jail sentence. At the same time, Gray confirmed that he referred to Thompson as “Uncle Earl.” But he said he was seeking to keep the businessman’s identity hidden from his opponent in 2010, then-Mayor Adrian M. Fenty, who was also receiving money from Thompson.

Thompson said in court that his secret spending went well beyond his support for Gray and that he made illegal contributions to more than two dozen federal and local candidates between 2006 and 2012.

In the most high-profile instance, Thompson in 2008 secretly spent more than $600,000 on canvassers and campaign materials to reach voters on behalf of Hillary Rodham Clinton during five primary contests with then-Sen. Barack Obama. While Machen did not identify Clinton by name on Monday, he specifically said that the presidential candidate referenced in court documents was not aware of the illegal effort.

In court, Thompson, once a powerful force in District politics with a vast network of allies, stood for nearly an hour as U.S. District Judge Colleen Kollar-Kotelly quizzed him about his efforts to influence federal and District elections.

In regard to his support for Gray, Thompson wanted to keep their pact secret to avoid retribution from Fenty, according to his agreement. Thompson hoped that Gray’s ascension to the mayor’s office would create new opportunities for his health-care company, he told prosecutors.

“Mayor Gray asked you to pay for the get-out-the-vote effort?” the judge asked.

“Yes, your honor,” Thompson said.

“And you agreed to pay for it?” the judge continued.

“Yes,” Thompson answered as reporters, lawyers and community activists jamming the courtroom watched from the gallery.

According to the plea deal, Thompson and Gray had at least two conversations specifically about the contractor’s support. Three days before a deadline to report contributions, Gray urged Thompson to “accelerate his fundraising,” the businessman told prosecutors. Thompson collected the checks, many of them donations from other individuals whom the businessman then illegally reimbursed.

Thompson said in court that Gray and most of the other candidates he supported knew about his unreported “shadow” campaigns.

At one point during the 2010 mayoral race, Thompson said, a Gray associate asked him for more than $400,000 to finance a plan to get voters to the polls on Election Day.

In response, Thompson said he insisted that Gray ask for the money himself. During a meeting at the apartment of a Gray associate, prosecutors said, Gray presented Thompson with his budget for the get-out-the-vote campaign and “expressed gratitude” for the assistance.

After the election, prosecutors said, Thompson gave a $10,000 check to Gray’s “close family member” to settle debts with campaign workers. At Gray’s request, Thompson also gave $10,000 to fund a unnamed union election campaign.

Later, after Gray was inaugurated, Thompson gave $40,000 to the mayor’s “close personal friend” in part to finance home improvements, Assistant U.S. Attorney Michael Atkinson said.

Subsequently, prosecutors said, Thompson appealed to Gray, through an associate, Jeanne Clarke Harris, to “expedite” a pending settlement with the city involving his firm, D.C. Chartered Health Plan.

When asked in court whether Harris had talked to the mayor, Thompson said, “Based on what Miss Harris told me, yes.”

Thompson soon learned that the District government was “resolving the matter,” according to his plea agreement.

Investigators have been looking at the city’s decision to pay Thompson’s health-care company $7.5 million to settle a dispute over reimbursements that had begun during the Fenty administration. Investigators have explored what role, if any, Gray and his deputies played in the 2011 deal.

The mayor has said that Thompson never asked him for any favors, and city officials have defended the Chartered settlement as aboveboard and equitable.

Thompson’s defense team and prosecutors had been negotiating a deal for weeks, finalizing an agreement Friday. He pleaded guilty to one count each of conspiring to break federal and local campaign finance laws and could face up to six months in prison. If he had been convicted at trial, he could have faced up to five years in prison.

Beyond Gray’s 2010 campaign, prosecutors say, Thompson secretly spent $812,146 in support of seven candidates for mayor and D.C. Council. The new court filing estimates that Thompson spent about $668,800 on campaign materials and services for Gray — more than has been previously reported.

Seven people connected to Thompson or affiliated with Gray’s last campaign have pleaded guilty in federal court in the past two years. Prosecutors have alluded to Thompson in case after case, but until Monday he had been identified in court documents only as an unnamed co-conspirator.

During much of the investigation, Thompson attorney Brendan V. Sullivan Jr. publicly showed no interest in negotiating with Machen’s office. He fought the government over certain documents seized in raids in 2012, appealing late last year to the Supreme Court.

Atkinson, the prosecutor, said in court that Thompson earlier in the investigation “had destroyed documents relevant” to the case.

In recent weeks, however, Thompson’s defense team has been sharing information with prosecutors as part of plea talks.

Court papers filed Monday do not name any candidates. At the judge’s prompting on Monday, prosecutors referred to Gray by name in court.

Documents and interviews with people familiar with the contributions show that Thompson spent about $278,000 for the 2006 mayoral campaign of Democrat Linda W. Cropp. He also spent smaller amounts on behalf of former council member Michael A. Brown in 2007 and 2008 and the council candidacy of Mark H. Long, an independent, in 2008.

In 2010, Thompson backed Democratic council hopefuls Jeff Smith ($140,000) and Kelvin Robinson ($26,000), and he spent about $148,000 for council member Vincent B. Orange (D-At Large) in 2011. None of the contributions were reported as required by local campaign finance laws.

Thompson told the judge he did not communicate with Cropp or Orange directly about the illegal funds.

In addition to the shadow campaigns, Thompson also arranged $250,000 in illegal conduit donations — made in the names of family, friends and colleagues but later reimbursed through his accounting firm and personal accounts. The donations went to at least 13 federal candidates for the Senate and House of Representatives, including Del. Eleanor Holmes Norton (D-D.C.) and then-Sen. Arlen Specter (D-Pa.).

Thompson and his attorneys declined to comment after the hearing.

As details emerged from the courtroom, D.C. Council Chairman Phil Mendelson (D) urged calm.

“This is all coming to us as a matter of first impressions. We need to sift through all of the facts to understand it,” Mendelson said. He said with the primary only weeks away, the four council members on the ballot “should stay out of this for the moment. “

They did not.

Council member Tommy Wells (D-Ward 6), who is challenging Gray, said it was a “sad day” for the District. If the allegations are true, he said, Gray “absolutely is disqualified” from serving as mayor any longer.

Aaron C. Davis, Mike DeBonis and Marc Fisher contributed to this report.