With just three weeks to go until the April 1 Democratic primary, the race for D.C. mayor all but started over on Monday, when prosecutors accused incumbent Vincent C. Gray of helping to orchestrate an illegal “shadow campaign” that helped propel him to office four years ago.

Before the revelations, Gray appeared to be on his way to threading a political needle, holding a significant lead in recent polls among a crowded and closely divided field.

Now, the contest has turned into a referendum on whether voters believe Gray. And he appeared to be acutely aware of that Monday, when he sat for interviews with the city’s news outlets to give each a direct and dramatic denial.

Jeffrey E. Thompson, a self-made accounting and health-care mogul, admitted in court Monday to doling out hundreds of thousands of dollars in illegal campaign cash to Gray and dozens of others in 2010.

Gray described Thompson’s claims as the dissembling of a criminal caught red-handed and willing to say anything to reduce his punishment. He denied involvement in the scheme more forcefully than ever, saying: “Lies. They are lies.” He also showed little sign of bowing to U.S. Attorney Ronald C. Machen Jr.’s request that those involved in Thompson’s schemes “come forward now and own up to your conduct.”

“I’ve addressed that now for what, three years? My story’s the same,” he said. “My answers are the same. They are not changing.”

But Gray faces a daunting challenge: to hold together his base of support while his opponents — and perhaps prosecutors — ratchet up the pressure.

“I promise you, we are not going away,” Machen said, adding that he intended to lift a “veil of corruption” from the city over the course of months or longer.

Until Monday, Gray was largely immune to a collection of mostly small-bore policy attacks waged against him by a wide field of opponents. The mayor’s approval ratings have remained high, and the city’s economic growth has insulated him from criticism.

But the federal investigation was always looming in the background.

Gray’s primary opponents leapt at the chance Monday to place the investigation front and center — including some who previously trod lightly on the matter. “The citizens of our great city are witnesses to a flagrant betrayal of the public trust,” said D.C. Council member Muriel Bowser (Ward 4), who led her fellow challengers in the most recent public poll of the race.

“It reminds me of the crisis situation after Marion Barry was arrested,” said council member Jack Evans (Ward 2). “Everyone needs to do what is in the best interest of the city. . . . It may be that the mayor getting out of the race is what’s best for the city, but that’s his decision to make.”

Council member Tommy Wells (Ward 6) — who has run on a good-government platform, decrying a “culture of corruption” that Thompson has come to represent — said, “If any of these allegations are true, then not only should he not run for reelection, he should step down.”

And late Monday, council member David A. Catania (I-At Large) announced that he will run for mayor, facing the winner of the April 1 primary in November’s general election.

It is not the first time Gray has faced calls for his resignation. When the outlines of the Thompson-funded shadow campaign were revealed in July 2012, three council members — including Bowser and Catania, but not Wells — urged Gray to step down. A Washington Post poll published shortly thereafter found that a majority of residents agreed.

“This is not the campaign that we intended to run,” Gray said at the time.

He remained in office, and the federal investigation entered a quieter phase. A year and a half later, with the city on the upswing, he was in a position to open a plausible bid for a second term. Recent surveys put his job-approval rating at over 50 percent.

Faced with the new revelations, Gray appears to be following a similar playbook: Go about business as usual and hope the bad headlines blow over.

On Tuesday evening, Gray is set to deliver his fourth State of the District address at a middle school in his home Ward 7, where, according to aides familiar with the speech, he is expected to announce a major new commitment to education funding.

The timing of Thompson’s plea agreement, however, undermines Gray’s electoral strategy of asking voters to focus on his administration’s accomplishments rather than the allegations against a nearly four-year-old campaign.

Attention has been refocused on new, specific allegations about Gray’s role in and knowledge of the illicit 2010 activities:

●That Gray understood that Thompson could not support his mayoral campaign through the usual channels, because that might threaten Thompson’s business relationship with the city under then-Mayor Adrian M. Fenty.

●That Gray rode during the campaign in a luxury sport-utility vehicle leased with unreported Thompson money and was driven by Mark H. Long, a campaign associate who was paid with unreported Thompson money.

●That Gray met with Thompson and asked him to spend $425,000 on shadow get-out-the-vote efforts, presenting him with a one-page budget with proposed outlays.

Aside from Gray’s denial Monday, a broader defense began to emerge in interviews with him and comments from his administration and political aides.

Most of the conduct alleged in Thompson’s plea, they said, despite being perhaps an unflattering depiction of backroom political dealings, was not illegal. One example, they said: Gray pressuring Thompson to deliver campaign checks ahead of a reporting deadline or encouraging him to support a union official’s election campaign.

What Gray and his aides did not do Monday was question Machen. Instead, they sought to impugn Thompson.

Campaign manager Chuck Thies walked up to the edge of criticizing the city’s top federal prosecutor, questioning the terms of Thompson’s plea deal.

“The man who tried to change the course of history is only going to jail for six months?” he said. “After spending $2.8 million, after violating federal laws and local law, after orchestrating a massive conspiracy involving tens if not dozens of people? . . . He cleared out a sweetheart deal for himself, and he’s clearly willing to say anything to take care of himself.”

Gray may have bigger worries than a hostile campaign trail. Machen declined to say whether the mayor is cooperating or whether he will be charged. But Machen made clear Monday that he will not hesitate to take further action in the coming weeks, regardless of the election. The investigation has entered a new phase, he said, in which his office will “seek to hold accountable all of those who helped hide the truth from the public.”

“I don’t feel there is a timetable,” he said. “My responsibility is to move forward when there’s evidence to move forward.”

Aaron C. Davis contributed to this report.