The Daily Mail, a British tabloid, was first with the salacious story: Anthony D. Weiner, the former New York congressman, had exchanged sexually charged messages with a 15-year-old girl.
The article, appearing in late September, raised the possibility that Mr. Weiner had violated child pornography laws. Within days, prosecutors in Manhattan sought a search warrant for Mr. Weiner’s computer.
Even with his notoriety, this would have had little impact on national politics but for one coincidence. Mr. Weiner’s wife, Huma Abedin, was one of Mrs. Clinton’s closest confidantes, and had used an email account on her server.
F.B.I. agents in New York seized Mr. Weiner’s laptop in early October. The investigation was just one of many in the New York office and was not treated with great urgency, officials said. Further slowing the investigation, the F.B.I. software used to catalog the computer files kept crashing.
Eventually, investigators realized that they had hundreds of thousands of emails, many of which belonged to Ms. Abedin and had been backed up to her husband’s computer.
Neither Mr. Comey nor Ms. Lynch was concerned. Agents had discovered devices before in the Clinton investigation (old cellphones, for example) that turned up no new evidence.
Then, agents in New York who were searching image files on Mr. Weiner’s computer discovered a State Department document containing the initials H.R.C. — Hillary Rodham Clinton. They found messages linked to Mrs. Clinton’s home server.
And they made another surprising discovery: evidence that some of the emails had moved through Mrs. Clinton’s old BlackBerry server, the one she used before moving to her home server. If Mrs. Clinton had intended to conceal something, agents had always believed, the evidence might be in those emails. But reading them would require another search warrant, essentially reopening the Clinton investigation.
The election was two weeks away.
Mr. Comey learned of the Clinton emails on the evening of Oct. 26 and gathered his team the next morning to discuss the development.
Seeking a new warrant was an easy decision. He had a thornier issue on his mind.
Back in July, he told Congress that the Clinton investigation was closed. What was his obligation, he asked, to acknowledge that this was no longer true?
It was a perilous idea. It would push the F.B.I. back into the political arena, weeks after refusing to confirm the active investigation of the Trump campaign and declining to accuse Russia of hacking.
The question consumed hours of conference calls and meetings. Agents felt they had two options: Tell Congress about the search, which everyone acknowledged would create a political furor, or keep it quiet, which followed policy and tradition but carried its own risk, especially if the F.B.I. found new evidence in the emails.
“In my mind at the time, Clinton is likely to win,” Mr. Steinbach said. “It’s pretty apparent. So what happens after the election, in November or December? How do we say to the American public: ‘Hey, we found some things that might be problematic. But we didn’t tell you about it before you voted’? The damage to our organization would have been irreparable.”
Conservative news outlets had already branded Mr. Comey a Clinton toady. That same week, the cover of National Review featured a story on “James Comey’s Dereliction,” and a cartoon of a hapless Mr. Comey shrugging as Mrs. Clinton smashed her laptop with a sledgehammer.
Credit Doug Mills/The New York Times
Congressional Republicans were preparing for years of hearings during a Clinton presidency. If Mr. Comey became the subject of those hearings, F.B.I. officials feared, it would hobble the agency and harm its reputation. “I don’t think the organization would have survived that,” Mr. Steinbach said.
The assumption was that the email review would take many weeks or months. “If we thought we could be done in a week,” Mr. Steinbach said, “we wouldn’t say anything.”
The spirited debate continued when Mr. Comey reassembled his team later that day. F.B.I. lawyers raised concerns, former officials said. But in the end, Mr. Comey said he felt obligated to tell Congress.
“I went back and forth, changing my mind several times,” Mr. Steinbach recalled. “Ultimately, it was the right call.”
That afternoon, Mr. Comey’s chief of staff called the office of Ms. Yates, the deputy attorney general, and revealed the plan.
When Ms. Lynch was told, she was both stunned and confused. While the Justice Department’s rules on “election year sensitivities” do not expressly forbid making comments close to an election, administrations of both parties have interpreted them as a broad prohibition against anything that may influence a political outcome.
Ms. Lynch understood Mr. Comey’s predicament, but not his hurry. In a series of phone calls, her aides told Mr. Comey’s deputies that there was no need to tell Congress anything until agents knew what the emails contained.
Either Ms. Lynch or Ms. Yates could have ordered Mr. Comey not to send the letter, but their aides argued against it. If Ms. Lynch issued the order and Mr. Comey obeyed, she risked the same fate that Mr. Comey feared: accusations of political interference and favoritism by a Democratic attorney general.
If Mr. Comey disregarded her order and sent the letter — a real possibility, her aides thought — it would be an act of insubordination that would force her to consider firing him, aggravating the situation.
In the letter, the F.B.I. director, James B. Comey, said that new emails had surfaced in a case unrelated to the closed investigation into whether Hillary Clinton or her aides had mishandled classified information, and that the messages “appear to be pertinent to the investigation.”
So the debate ended at the staff level, with the Justice Department imploring the F.B.I. to follow protocol and stay out of the campaign’s final days. Ms. Lynch never called Mr. Comey herself.
The next morning, Friday, Oct. 28, Mr. Comey wrote to Congress, “In connection with an unrelated case, the F.B.I. has learned of the existence of emails that appear to be pertinent to the investigation.”
His letter became public within minutes. Representative Jason Chaffetz of Utah, a Republican and a leading antagonist of Mrs. Clinton’s, jubilantly announced on Twitter, “Case reopened.”