Jeffrey Thompson’s full accounting of the 2010 campaign has the potential to implicate D.C. Mayor Vincent Gray in wrongdoing or clear Gray’s name. (Jason Miccolo Johnson)

Jeffrey E. Thompson, the prominent D.C. businessman whom investigators consider the architect of an illegal campaign effort for Mayor Vincent C. Gray four years ago, is in the final stages of talks with federal prosecutors to strike a plea agreement, according to several people familiar with the discussions.

The negotiations, which signal a major advance in the corruption probe that has encircled the mayor, come three weeks before voters choose a Democratic nominee for the city’s chief executive. Gray (D), who has said he did nothing wrong, is seeking reelection and leads in polls as the April 1 primary approaches.

For nearly three years, federal prosecutors have been methodically building a case against Thompson. Associates have said in court that Thompson secretly funneled more than $650,000 to a “shadow campaign” on Gray’s behalf. Seven people connected to Thompson or affiliated with Gray’s 2010 campaign have pleaded guilty in federal court in the past two years and have outlined Thompson’s alleged efforts to subvert local and federal campaign finance laws.

Thompson is a critical figure in the probe, because his full accounting of the 2010 campaign has the potential to implicate Gray in wrongdoing or clear his name. Prosecutors consider Thompson the key to learning the details of conversations he may have had about the illegal campaign. They also view him as critical to understanding the level of Gray’s knowledge of the scheme.

Thompson attorney Brendan V. Sullivan Jr., a tenacious litigator, has publicly shown no interest in striking a deal with the office of U.S. Attorney Ronald C. Machen Jr. Sullivan has engaged in extensive legal wrangling — going to the Supreme Court in one key instance — to block prosecutors from reviewing certain documents seized in a 2012 search of Thompson’s home and offices.

Sullivan was out of town Thursday and unavailable to comment. Other lawyers on the team declined to comment. The people with knowledge of the talks cautioned that there is no final agreement and that negotiations sometimes fall apart.

In recent weeks, Thompson’s defense team has been sharing information with prosecutors as part of possible plea negotiations to resolve his case without a trial or a courtroom battle, according to two people who spoke on the condition of anonymity because they were not authorized to talk about the private discussions.

It is unclear what Thompson has told federal investigators and what he is saying about Gray. If Thompson pleads guilty before the April 1 primary, the prosecutors’ outline of the allegations could provide D.C. voters with more insight into Gray’s 2010 campaign.

A spokesman for the U.S. attorney’s office declined to comment Thursday.

Prosecutors have not accused the mayor of a crime. He has apologized to residents and has acknowledged the “misdeeds and missteps” of his associates. But Gray has declined to answer specific questions from reporters about what, if anything, he knew about Thompson’s alleged secret efforts and when he learned about them.

During a candidates’ forum last week on WAMU (88.5 FM), Gray was asked whether voters deserve a “detailed accounting of what happened” during his 2010 campaign.

“I’ve indicated I tried to provide what information I know,” Gray responded before quickly veering to highlight of his personal story, growing up in a one-bedroom D.C. apartment and working hard as a public servant for city residents.

The cloud of the federal investigation and unanswered questions have hung over the city and the mayoral campaign, dogging Gray as he made his decision about whether to seek a second term. Without a resolution to the three-year-long probe, voters have faced the prospect of going to the polls without knowing what investigators have learned about possible interactions between Thompson and Gray.

In November, Machen took the unusual step of commenting publicly on the status of the investigation and its potential to influence the election. The city’s top prosecutor said he would not allow the campaign schedule to dictate his timeline for bringing charges.

“We can’t just wrap up an investigation when we’re still in the midst of gathering information,” he said at a Capitol Hill community center during a question-and-answer session.

The timetable for a potential plea deal is a tricky matter for Machen’s office. Election-year guidelines issued in 2012 by Attorney General Eric H. Holder Jr. prohibit prosecutors from intentionally timing criminal charges or investigative steps with the goal of influencing an election or candidate. But prosecutors are also advised to bring indictments and take other actions that are appropriate as their case builds. There are no specific Justice Department policies that would prevent Machen from moving ahead with a deal with Thompson so close to the election.

A recent Washington Post poll found that more than 40 percent of Democrats say the federal investigation will be a major factor in how they vote. The survey also found that voters’ concerns about Gray’s trustworthiness are his most significant weakness despite general approval of his tenure as mayor.

Machen has also appealed to the public for patience with the long-running investigation.

“It’s not like we’ve been looking at this for three years and there’s no ‘there’ there. I mean, there’s ‘there’ there,” he said last fall. “We’re trying to gather information, we’re trying to get documents and we’re trying to talk to people.”

Thompson, 58, was a major city contractor as the owner of the District’s dominant Medicaid provider and ran an accounting firm. As part of the probe, investigators have reviewed the city’s decision to enter into a $7.5 million settlement with Thompson’s D.C. Chartered Health Plan and 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 settlement as aboveboard and equitable.

Beyond the shadow campaign for Gray, Machen has said that Thompson’s former accounting firm was an “assembly line” for illegal “straw donations” to a long list of local and federal candidates.

Court filings and interviews also identify Thompson as the source of off-the-books campaign efforts in other elections, including for Hillary Rodham Clinton’s 2008 presidential bid and former D.C. council member Michael A. Brown’s 2008 race.

Mike DeBonis contributed to this report.