FBI agents were stunned to find thousands of Hillary Clinton’s private emails while examining Anthony Weiner’s electronic devices for explicit text messages with a teen girl, a new book alleges.

The agents called the discovery an “oh sh-t” moment as they combed through Weiner’s iPhone, iPad and laptop after it was revealed he had been sending inappropriate messages to a minor, journalist James B. Stewart claims in his new book “Deep State: Trump, the FBI, and the Rule of Law,” out Tuesday.

Within hours of the Sept. 26, 2016, search warrant, FBI technicians noticed there were 340,000 emails on the laptop between Clinton and her top aide, Weiner’s wife Huma Abedin — many of them from domain addresses such as “hillaryclinton.com” and “state.gov.”

At an FBI briefing later that week, one participant said the revelation was like “dropping a bomb in the middle of the meeting.”

But the discovery fell through the cracks because top FBI officials were “overwhelmed” by the Russia probe, Stewart wrote.

A determined New York FBI agent was “scared” by what he had found and pressed his superiors to finish the job.

“I’m telling you that we have potentially ten times the volume that Director Comey said we had on the record,” the agent recounted to Stewart. “Why isn’t anybody here?”

The book also revealed how former FBI lawyer Lisa Page lied to bosses at the bureau about her affair with agent Peter Strzok — telling FBI Deputy Director Andrew McCabe the pair were never romantically involved.