Former President Donald J. Trump has a lot at stake in the federal criminal case lodged against him. He could, in theory, go to prison for years. But if he winds up in the dock in front of a jury, it is no exaggeration to suggest that American justice will be on trial as well.

History’s first federal indictment against a former president poses one of the gravest challenges to democracy the country has ever faced. It represents either a validation of the rule-of-law principle that even the most powerful face accountability for their actions or the moment when a vast swath of the public becomes convinced that the system has been irredeemably corrupted by partisanship.

Mr. Trump, his allies and even some of his Republican rivals have embarked on a strategy to encourage the latter view, arguing that law enforcement has been hijacked by President Biden and the Democrats to take out his strongest opponent for re-election next year. Few if any of them bothered to wait to read the indictment before backing Mr. Trump’s all-caps assertion that it was merely part of the “GREATEST WITCH HUNT OF ALL TIME.” It is now an article of faith, a default tactic or both.

Jack Smith, the special counsel, and his prosecutors knew that defense was coming and have labored to avoid any hint of political motivation with a by-the-book approach, securing the assent of judges and grand jurors along the way. Moreover, their indictment laid out a damning series of facts based on security camera video, text messages and testimony from within Mr. Trump’s own team; even some who have defended him in the past say it will be harder to brush aside the evidence in a courtroom than in the court of public opinion.

In the public arena, though, it may be a one-sided fight. Mr. Trump and his allies can scream as loudly as they can that the system is unfair, but prosecutors are bound by rules limiting how much they can say in response. To the extent that Democrats defend prosecutors, it may only buttress the point Mr. Trump is trying to make to the audience he is trying to reach.

“I think the verdict on democracy ultimately comes down to Republican leaders and Republican voters,” said David Jolly, a former Republican congressman from Florida who left the party during the Trump presidency. “Their current weaponization narrative is dangerous and destabilizing, but seems to reflect the party’s early consensus. If they don’t pivot soon to due process and faith in the system, I think we could have very dark days ahead. I do worry.”

Polls suggest that Mr. Trump has made headway in persuading at least his own supporters that any and all allegations against him are just political. After he was indicted in March by the Manhattan district attorney on state charges related to hush money paid to an adult film actress, the former president’s support among Republicans rose, rather than fell.

While 60 percent of all adults surveyed by CNN afterward approved of the charges, 76 percent agreed that politics played a role in the prosecution. As for the effect on America’s system, 31 percent said the indictment strengthened democracy, while 31 percent said it weakened it.

All of which indicates that the system’s credibility is on the line in a way it has not been before. Many have criticized American justice over the years for systemic racism, excessive punishment, mistreatment of women subjected to assault or other issues, but they did not command the bullhorn of the presidency. When past presidents like Richard M. Nixon or Bill Clinton got in trouble, they defended themselves aggressively, but did not call the whole system into question.

“In 1972 to 1974, the Republicans participated as good-faith members of the process,” said Garrett Graff, the author of “Watergate: A New History,” published last year. “They saw their roles as legislators first and Republicans second. They definitely were skeptical” initially of the allegations against Nixon, “but they followed the facts where they led.”

Even Nixon’s sharp-tongued vice president, Spiro T. Agnew, was careful about disparaging the justice system broadly. “Agnew, of course, was Nixon’s attack dog, but mainly against the press, not the F.B.I. or the special prosecutor,” Mr. Graff said.

Mr. Trump, on the other hand, is holding nothing back as he assails “the ‘Thugs’ from the Department of Injustice” and calls Mr. Smith a “deranged lunatic.” Republicans like Representative Andy Biggs of Arizona have called for dismantling the F.B.I. “We have now reached a war phase,” he wrote on Twitter on Friday. “Eye for an eye.” Elon Musk said the authorities were showing “far higher interest in pursuing Trump compared to other people in politics.”

Several of Mr. Trump’s competitors for the Republican presidential nomination joined in. Former Vice President Mike Pence compared the indictment to leaders of “third-world nations” who “use a criminal justice system in their country against their predecessors.” Gov. Ron DeSantis of Florida said “the weaponization of federal law enforcement represents a mortal threat to a free society.”

The former president’s defenders generally do not address the substance of the 37 counts against him, but instead make a case of selective prosecution that resonates powerfully among many Republicans: What about Mr. Biden? What about Hunter Biden? What about Hillary Clinton?

They point to the origin of the Russia investigation against Mr. Trump, citing the recent report by the special counsel John H. Durham that harshly criticized the F.B.I. for its handling of the case even though it did not come up with any new blockbuster revelations of politically motivated misconduct nor result in the conviction of any major figure.

They point to Republican congressional inquiries that they say hint at wrongdoing by the Bidens even without confirmation. They point to the continuing federal criminal investigation of the president’s son Hunter, suggesting it has been impeded. And they point to the fact that the president himself is also under investigation over retaining classified documents yet not charged.

The differences between the cases, however, are stark, making apples-to-apples comparisons complicated. In the documents investigation, for instance, Mr. Biden’s advisers by all accounts so far returned the papers to the authorities promptly after discovering them. Mr. Pence did the same after a voluntary search found that the former vice president had kept classified documents, and he was recently cleared by the Justice Department because there was no evidence of willful violations of the law.

Mr. Trump, by contrast, refused to hand over all the documents he had taken from the White House — even after being subpoenaed for them. According to the indictment, he orchestrated an expansive scheme to hide papers and feed lies to authorities seeking them. On two occasions, the indictment charged, Mr. Trump showed secret documents to people without security clearance and indicated that he knew he was not supposed to.

As for seeking to weaponize the Justice Department, there was ample evidence that Mr. Trump sought to do just that while in office. He openly and aggressively pushed his attorneys general to prosecute his perceived enemies and drop cases against his friends and allies, making no pretense that he was seeking equal and independent justice. His friends-and-family approach to his pardon power extended clemency to associates and those who had access to him through them.

He chipped away at so many norms during his four years in office that it is no wonder that institutions have faced credibility problems. Indeed, he has made clear that he does not respect the boundaries that constrained other presidents. Since leaving office, he has called for “termination” of the Constitution so that he could be returned to power without waiting for another election and vowed that he would devote a second term to “retribution” against his foes while pardoning supporters who stormed the Capitol on Jan. 6, 2021, to stop the transfer of power.

There is no known evidence, on the other hand, that Mr. Biden has played any role in the investigations against Mr. Trump. Unlike the voluble Mr. Trump, he has made a point of not even publicly commenting on individual prosecutions, saying he respects the autonomy of the Justice Department.

Attorney General Merrick B. Garland has been sensitive to the matter of perception and sought to insulate the inquiries by appointing Mr. Smith, a career prosecutor who is not registered with either political party, as a special counsel with a guarantee of independence absent manifest wrongdoing on his part.

But that was never going to convince Mr. Trump or his most fervent supporters of the fairness of the process. At bottom, the former president and front-runner for his party’s nomination to be the next president is being charged by a prosecutor appointed by an appointee of the man he hopes to beat. It is a recipe for distrust, especially when stoked by a defendant who has mastered the politics of grievance and victimhood.

Will that result in lasting damage to democracy? Even some who support charging Mr. Trump fear that it may. Still, some who have studied politically fraught investigations counseled patience. There will be fireworks. Many will doubt the credibility of the system. But in the end, they said, the system will survive just as it has for more than two centuries.

“It’s messy and uncomfortable for the generation living through it, but the system is durable enough to win out,” said Ken Gormley, the president of Duquesne University and the author of books on Watergate and the Clinton investigations. “As painful as the next year is likely to be as the criminal justice system grinds forward toward a fair verdict in the Mar-a-Lago documents case — whatever that outcome may be — we are fortunate that our predecessors have spent 234 years shoring up the bulwark.”