Get breaking news alerts and special reports. The news and stories that matter, delivered weekday mornings.

It’s hardly a perfect outcome to her long email saga, but Hillary Clinton will take it.

In a surprise announcement Tuesday, FBI Director James Comey delivered a stinging rebuke of Clinton’s “extremely careless” handling of classified information on the private email server she used as secretary of state, delivering months worth of negative TV ad fodder to her political opponents.

But the tongue lashing was a relatively light sentence compared to what could have been: criminal prosecution. And it means that Clinton’s long email nightmare is finally coming to a close.

"We are pleased that the career officials handling this case have determined that no further action by the Department is appropriate. As the Secretary has long said, it was a mistake to use her personal email and she would not do it again. We are glad that this matter is now resolved,” Clinton spokesman Brian Fallon said in a statement.

An indictment easily could have become a mortal wound for Clinton.

Whether it led to a behind-closed-doors reshuffling inside the Democratic Party to pick a new nominee or the slow bloodletting of attacks over the next five months, Clinton would have had a hard time winning the presidency while facing criminal charges.

Department of Justice prosecutors could still overrule the FBI and decide to move ahead with prosecution, but experts have long said charges are unlikely.

Let our news meet your inbox. The news and stories that matters, delivered weekday mornings. This site is protected by recaptcha

Related: FBI Recommends No Criminal Charges Against Hillary Clinton

The political fallout will be painful, as Comey showed Clinton little mercy, saying she should have known better.

Contradicting Clinton’s claims that she never sent or received classified information over an unsecured server, Comey said her server did contain such material and that her system made it more vulnerable to foreign hackers.

“None of these e-mails should have been on any kind of unclassified system, but their presence is especially concerning because all of these e-mails were housed on unclassified personal servers not even supported by full-time security staff,” Comey said.

Clinton already suffers from poor ratings on trust and honesty, and Comey’s remarks make it impossible for Democrats to claim the email issue was just the latest invention of a right-wing conspiracy out to get her.

More than four in 10 voters say Donald Trump is better at “being honest and straightforward” than Clinton, according to a recent NBC News/Wall Street Journal poll, while just 25 percent said the same of Clinton.

But at least the fallout is only political, and not legal. Over their decades in public life, the Clintons have survived special prosecutors, congressional probes, FBI investigations, lawsuits, and impeachment. A few more days dealing with the politics of scandal is just another more few days in the life of Hillary Clinton.

Related: Obama Campaigns With Clinton Amid FBI Investigation

And much of the damage may already be accounted for. While the FBI’s finding could sway some voters who had planned to vote for Clinton or were undecided, the voters who care most about it were probably already voting against her anyway.

Trump, Clinton’s rival in the general election, understood that this was the lesser of two bad options for Clinton.

“FBI director said Crooked Hillary compromised our national security. No charges. Wow! #RiggedSystem,” Trump tweeted. “General Petraeus got in trouble for far less. Very very unfair! As usual, bad judgment.”

Petraeus was charged for keeping highly classified information, including the names of covert agents, in private journals and then turning them over to his biographer-turned-mistress. Legal experts say the law is far harsher with those who intentionally compromise information than those who do so accidentally.

Comey’s announcement came on Tuesday, the same day that President Obama is set to make his debut on the stump with Clinton in Charlotte, North Carolina. The two former rivals will ride down together aboard Air Force One.

Aware of the political realities, Comey said he had not alerted other components of the U.S. government, including the White House, about the news he had prepared to deliver Tuesday.

And he stressed — especially in light of Bill Clinton’s recent meeting with Attorney General Loretta Lunch, Comey’s boss — that no one influenced the bureau’s investigation.