WASHINGTON — The FBI’s recommendation against criminal charges in the Hillary Clinton email matter drew immediate comparisons to last year’s high-profile case in which the agency took the opposite position and pursued the prosecution of then-CIA Director David Petraeus.

The Petraeus case, long seen by some as a potentially analogous investigation into the mishandling of government secrets, resurfaced within minutes of the FBI’s announcement on Tuesday when Republican presidential Donald Trump tweeted: “The system is rigged. General Petraeus got in trouble for far less.”

But that statement is dubious. Though both investigations examined the handling of classified information by powerful government officials, and both drew the attention of the highest-ranking officials of the FBI and the Justice Department, the probes are separated by critical distinctions.

In Clinton’s case, for instance, FBI Director James Comey said that though the former secretary of her state and her aides had been “extremely careless” with classified information that flowed through her private email server, there was no evidence that anyone intended to violate laws that govern the handling of secret records.

Yet when Petraeus pleaded guilty last year to knowingly sharing binders of classified information with his biographer, a woman with whom he was having a sexual relationship, the Justice Department made clear that the retired Army general knew the material was top secret when he divulged it and had lied to the FBI about it.

Petraeus told Paula Broadwell, his biographer, in a recorded conversation in 2011 that the black books he was giving her were “highly classified” and contained “code word stuff,” prosecutors said. A year later, he told FBI agents who questioned him that he had never shared classified information with Broadwell.

Though he was never charged with making false statements, Petraeus pleaded guilty to a misdemeanor count of unauthorized removal and retention of classified. Information. He received probation and no prison time under his plea deal.

That misdemeanor outcome, in a case prosecutors said involved evidence of a false statement and willful mishandling, struck some legal experts and law enforcement officials as overly generous and likely made it much harder to bring any charges in the Clinton investigation — a case Comey said was lacking in criminal intent.

“The evidence in the Petraeus case of willfulness was significant,” said James Melendres, a former Justice Department prosecutor and the lead prosecutor in that case. “The false statement was an aggravating feature.”

Those are among the elements of a crime that the FBI looks for in investigations concerning the mishandling of classified information, Comey said Tuesday. The cases that prosecuted for that offense historically involve intentional or willful mishandling of classified information, signs of disloyalty to the United States, efforts to obstruct justice or the disclosure of vast quantities of secret records.

“We do not see those things here,” he said.

The Petraeus case is “more in line with the types of cases that have been prosecuted, which is when information was clearly marked or there is a significant amount of it in paper,” said Mark Zaid, a Washington national security lawyer.

Even so, Comey, in an extraordinary public statement at FBI headquarters, left no doubt that the FBI had detected significant problems in her email practices as secretary of state.

The FBI chief said that in the course of the investigation, 113 emails were determined to contain classified information at the time they were sent or received. He also said that “several thousand work-related emails” were not among the group of 30,000 that Clinton turned over in 2014.

He said there was evidence of “potential violations of the statutes regarding the handling of classified information.” But, he said, there was no evidence that anyone intended to violate any laws and that the FBI’s judgment was “no reasonable prosecutor would bring such a case.”

Criminal charges could theoretically have been brought but would “definitely have created a new precedent” given the large number of government officials who are similarly lax in their treatment of sensitive records, Zaid said.

“While it could have been prosecuted, I think as a practical reality, the precedent it would have created would have had far-reaching ramifications throughout the entire system,” he said.