WASHINGTON — Donald Trump, on the campaign trail, would occasionally compare the criminal investigation into whether Hillary Clinton mishandled classified information to the case of former CIA director David Petraeus. In Trump’s view, Petraeus, who pleaded guilty to mishandling classified information, was pursued unfairly, while Clinton deserved to be treated more harshly.

“The system is rigged,” Trump tweeted after the FBI recommended Clinton not be charged. “General Petraeus got in trouble for far less. Very very unfair! As usual, bad judgment.”

That assessment has long irked Clinton supporters and even the FBI — which feels Petraeus’ case was a clear cut example of criminal wrongdoing with aggravating factors, while Clinton’s was not. And now, Petraeus is under consideration for a job in Trump’s administration — possibly even as secretary of state, the job Clinton used to hold.

Petraeus and Trump met earlier this week, and Trump wrote on Twitter that he was “very impressed!”

If nominated to be secretary of state, Petraeus would have to undergo a potentially bruising confirmation hearing that would likely re-examine the lurid case that led to his conviction and dredge up old comparisons to Clinton. His and Clinton’s cases both involve investigations of mishandling of classified information, but under dramatically different circumstances.

Petraeus pleaded guilty last year to a misdemeanor charge of mishandling classified information, admitting that he gave sensitive materials to his former lover and biographer, Paula B roadwell. He was sentenced to two years of probation and a $100,000 fine. His probation includes several restrictions that could complicate his holding a Cabinet position, including that he must get his work-related travel approved by the U.S. Probation Office and that he submit to warrantless searches by his probation officer at any time.

Petraeus’ probation expires in April 2017, and Trump, upon taking office, could commute his sentence. A lawyer for Petraeus and other Petraeus associates did not immediately return messages seeking comment, nor did the Trump transition team. The U.S. Probation Office in North Carolina, where Petraeus was convicted, also did not return a message seeking comment.

In a statement provided to The Washington Post earlier this year, Petraeus said: “I have turned the page on these matters, I am looking forward, and I will have no further comment. I resigned as CIA Director, publicly apologized for my conduct, and formally accepted responsibility.”

Those involved in the Petraeus case at one point contemplated much more serious charges of lying to the FBI and violating a section of the Espionage Act. Officials have said the information contained in the eight notebooks Petraeus gave to Broadwell could have caused grave damage to national security, if disclosed.

The information included, the officials said, war strategies and the identities of covert officers. Petraeus, too, told agents that he had not provided classified information to Broadwell or facilitated her obtaining it, which FBI Director James Comey said was a lie.

At a congressional hearing earlier this year, Comey asserted forcefully that the Petraeus case was worthy of prosecution, while the Clinton case was not. He said the Petraeus case “illustrates importantly the distinction” with the Clinton matter.

“So the question is, do you agree with the claim that Gen. Petraeus, and I quote, ‘got in trouble for far less,’ end of quote? Do you agree with that statement?” Rep. Elijah Cummings, D-Md., asked the FBI director.

“No, it’s the reverse,” Comey said.

“And what do you mean by that?” Cummings said.

“His conduct, to me, illustrates the categories of behavior that mark the prosecutions that are actually brought. Clearly intentional conduct. Knew what he was doing was a violation of the law. Huge amounts of information that — even if you couldn’t prove he knew it — it raises the inference that he did it. An effort to obstruct justice. That combination of things makes it worthy of a prosecution, a misdemeanor prosecution, but a prosecution nonetheless.”

FBI agents investigated Clinton to see whether classified information was mishandled because of her use of a private server while she was secretary of state. Comey said Clinton and her staff were “extremely careless” in how they handled sensitive material, and there was “evidence of potential violations of the statutes regarding the handling of classified information.” But Comey said that “no reasonable prosecutor” would actually bring a case against her.

Classified material did traverse Clinton’s private server. Information in 110 emails contained information sensitive enough to be classified at the time it was sent or received, and eight email chains included information properly classified as “top secret,” the highest level of classification, Comey said.

But Comey said agents could find no substantive evidence that Clinton intended to mishandle classified information, that she lied during her interview with agents, or that she made any efforts to obstruct justice. Clinton has said using the private server was a mistake and one she wishes she had not made.

Comey did not fully clear Clinton of any wrongdoing. Were an FBI employee to do what she did, Comey said, the employee might face professional consequences, such as a loss of a security clearance, suspension or even termination. But he said he did not feel she should be charged with a crime.

Petraeus — a retired Army general and former CIA director who left the agency amid revelations about his relationship with Broadwell — would need a security clearance to serve as secretary of state. The CIA suspended his security clearance after his conviction and it remains suspended, U.S. officials said. A CIA spokesman declined to comment. An Army spokesman said Petraeus’s clearance through the Army would have no longer been valid after he retired from the service. Petraeus has advised the White House on matters related to Iraq and the Islamic State since his conviction.

A criminal conviction would not automatically preclude Petraeus from obtaining a clearance. He would have to pass a background check that assesses his “strength of character, trustworthiness, honesty, reliability, discretion, and sound judgment, as well as freedom from conflicting allegiances and potential for coercion, and a willingness and ability to abide by regulations governing the use, handling, and protection of classified information,” according to information on the State Department’s website. Whether to grant a clearance is a “discretionary security decision based on judgments by appropriately trained adjudicative personnel,” according to the site.

A State Department official said the department would “not speculate on prospects for that process.

• The Washington Post’s Greg Miller contributed to this report.