WASHINGTON — The day before he upended the 2016 election, James B. Comey, the director of the Federal Bureau of Investigation, summoned agents and lawyers to his conference room. They had been debating all day, and it was time for a decision.
Mr. Comey’s plan was to tell Congress that the F.B.I. had received new evidence and was reopening its investigation into Hillary Clinton, the presidential front-runner. The move would violate the policies of an agency that does not reveal its investigations or do anything that may influence an election. But Mr. Comey had declared the case closed, and he believed he was obligated to tell Congress that had changed.
“Should you consider what you’re about to do may help elect Donald Trump president?” an adviser asked him, Mr. Comey recalled recently at a closed meeting with F.B.I. agents.
He could not let politics affect his decision, he replied. “If we ever start considering who might be affected, and in what way, by what we do, we’re done,” he told the agents.
But with polls showing Mrs. Clinton holding a comfortable lead, Mr. Comey ended up plunging the F.B.I. into the molten center of a bitter election. Fearing the backlash that would come if it were revealed after the election that the F.B.I. had been investigating the next president and had kept it a secret, Mr. Comey sent a letter informing Congress that the case was reopened.
What he did not say was that the F.B.I. was also investigating the campaign of Donald J. Trump. Just weeks before, Mr. Comey had declined to answer a question from Congress about whether there was such an investigation. Only in March, long after the election, did Mr. Comey confirm that there was one.
For Mr. Comey, keeping the F.B.I. out of politics is such a preoccupation that he once said he would never play basketball with President Barack Obama because of the appearance of being chummy with the man who appointed him. But in the final months of the presidential campaign, the leader of the nation’s pre-eminent law enforcement agency shaped the contours, if not the outcome, of the presidential race by his handling of the Clinton and Trump-related investigations.
A polling place in the Bronx on Election Day last November.
Hiroko Masuike / The New York Times
An examination by The New York Times, based on interviews with more than 30 current and former law enforcement, congressional and other government officials, found that while partisanship was not a factor in Mr. Comey’s approach to the two investigations, he handled them in starkly different ways. In the case of Mrs. Clinton, he rewrote the script, partly based on the F.B.I.’s expectation that she would win and fearing the bureau would be accused of helping her. In the case of Mr. Trump, he conducted the investigation by the book, with the F.B.I.’s traditional secrecy. Many of the officials discussed the investigations on the condition of anonymity because they were not authorized to speak to reporters.
Mr. Comey made those decisions with the supreme self-confidence of a former prosecutor who, in a distinguished career, has cultivated a reputation for what supporters see as fierce independence, and detractors view as media-savvy arrogance.
The Times found that this go-it-alone strategy was shaped by his distrust of senior officials at the Justice Department, who he and other F.B.I. officials felt had provided Mrs. Clinton with political cover. The distrust extended to his boss, Loretta E. Lynch, the attorney general, who Mr. Comey believed had subtly helped play down the Clinton investigation.
His misgivings were only fueled by the discovery last year of a document written by a Democratic operative that seemed — at least in the eyes of Mr. Comey and his aides — to raise questions about her independence. In a bizarre example of how tangled the F.B.I. investigations had become, the document had been stolen by Russian hackers.
The examination also showed that at one point, President Obama himself was reluctant to disclose the suspected Russian influence in the election last summer, for fear his administration would be accused of meddling.
Mr. Comey, the highest-profile F.B.I. director since J. Edgar Hoover, has not squarely addressed his decisions last year. He has touched on them only obliquely, asserting that the F.B.I. is blind to partisan considerations. “We’re not considering whose ox will be gored by this action or that action, whose fortune will be helped,” he said at a public event recently. “We just don’t care. We can’t care. We only ask: ‘What are the facts? What is the law?’”
But circumstances and choices landed him in uncharted and perhaps unwanted territory, as he made what he thought were the least damaging choices from even less desirable alternatives.
“This was unique in the history of the F.B.I.,” said Michael B. Steinbach, the former senior national security official at the F.B.I., who worked closely with Mr. Comey, describing the circumstances the agency faced last year while investigating both the Republican and Democratic candidates for president. “People say, ‘This has never been done before.’ Well, there never was a before. Or ‘That’s not normally how you do it.’ There wasn’t anything normal about this.”
‘Federal Bureau of Matters’
Attorney General Loretta E. Lynch and Mr. Comey during a news conference in Brooklyn in May 2015. Both had been federal prosecutors in New York, Mr. Comey in Manhattan and Ms. Lynch in Brooklyn.
Sam Hodgson for The New York Times
Mr. Comey owes his job and his reputation to the night in 2004 when he rushed to the Washington hospital room of John Ashcroft, the attorney general, and prevented Bush administration officials from persuading him to reauthorize a classified program that had been ruled unconstitutional. At the time, Mr. Comey, a Republican, was the deputy attorney general.
Years later, when Mr. Obama was looking for a new F.B.I. director, Mr. Comey seemed an inspired bipartisan choice. But his style eventually grated on his bosses at the Justice Department.
In 2015, as prosecutors pushed for greater accountability for police misconduct, Mr. Comey embraced the controversial theory that scrutiny of police officers led to increases in crime — the so-called Ferguson effect. “We were really caught off guard,” said Vanita Gupta, the Justice Department’s top civil rights prosecutor at the time. “He lobbed a fairly inflammatory statement, without data to back it up, and walked away.”
On other issues, Mr. Comey bucked the administration but won praise from his agents, who saw him as someone who did what he believed was right, regardless of the political ramifications.
“Jim sees his role as apolitical and independent,” said Daniel C. Richman, a longtime confidant and friend of Mr. Comey’s. “The F.B.I. director, even as he reports to the attorney general, often has to stand apart from his boss.”
The F.B.I.’s involvement with Mrs. Clinton’s emails began in July 2015 when it received a letter from the inspector general for the intelligence community.
The letter said that classified information had been found on Mrs. Clinton’s home email server, which she had used as secretary of state. The secret email setup was already proving to be a damaging issue in her presidential campaign.
Mr. Comey’s deputies quickly concluded that there was reasonable evidence that a crime may have occurred in the way classified materials were handled, and that the F.B.I. had to investigate. “We knew as an organization that we didn’t have a choice,” said John Giacalone, a former mob investigator who had risen to become the F.B.I.’s top national security official.
On July 10, 2015, the F.B.I. opened a criminal investigation, code-named “Midyear,” into Mrs. Clinton’s handling of classified information. The Midyear team included two dozen investigators led by a senior analyst and by an experienced F.B.I. supervisor, Peter Strzok, a former Army officer who had worked on some of the most secretive investigations in recent years involving Russian and Chinese espionage.
There was controversy almost immediately.
Responding to questions from The Times, the Justice Department confirmed that it had received a criminal referral — the first step toward a criminal investigation — over Mrs. Clinton’s handling of classified information. But the next morning, the department revised its statement.
“The department has received a referral related to the potential compromise of classified information,” the new statement read. “It is not a criminal referral.”
At the F.B.I., this was a distinction without a difference: Despite what officials said in public, agents had been alerted to mishandled classified information and in response, records show, had opened a full criminal investigation.
The Justice Department knew a criminal investigation was underway, but officials said they were being technically accurate about the nature of the referral. Some at the F.B.I. suspected that Democratic appointees were playing semantic games to help Mrs. Clinton, who immediately seized on the statement to play down the issue. “It is not a criminal investigation,” she said, incorrectly. “It is a security review.”
In September of that year, as Mr. Comey prepared for his first public questions about the case at congressional hearings and press briefings, he went across the street to the Justice Department to meet with Ms. Lynch and her staff.
Both had been federal prosecutors in New York — Mr. Comey in the Manhattan limelight, Ms. Lynch in the lower-wattage Brooklyn office. The 6-foot-8 Mr. Comey commanded a room and the spotlight. Ms. Lynch, 5 feet tall, was known for being cautious and relentlessly on message. In her five months as attorney general, she had shown no sign of changing her style.
At the meeting, everyone agreed that Mr. Comey should not reveal details about the Clinton investigation. But Ms. Lynch told him to be even more circumspect: Do not even call it an investigation, she said, according to three people who attended the meeting. Call it a “matter.”
Ms. Lynch reasoned that the word “investigation” would raise other questions: What charges were being investigated? Who was the target? But most important, she believed that the department should stick by its policy of not confirming investigations.
It was a by-the-book decision. But Mr. Comey and other F.B.I. officials regarded it as disingenuous in an investigation that was so widely known. And Mr. Comey was concerned that a Democratic attorney general was asking him to be misleading and line up his talking points with Mrs. Clinton’s campaign, according to people who spoke with him afterward.
As the meeting broke up, George Z. Toscas, a national security prosecutor, ribbed Mr. Comey. “I guess you’re the Federal Bureau of Matters now,” Mr. Toscas said, according to two people who were there.
Despite his concerns, Mr. Comey avoided calling it an investigation. “I am confident we have the resources and the personnel assigned to the matter,” Mr. Comey told reporters days after the meeting.
The F.B.I. investigation into Mrs. Clinton’s email server was the biggest political story in the country in the fall of 2015. But something much bigger was happening in Washington. And nobody recognized it.
While agents were investigating Mrs. Clinton, the Democratic National Committee’s computer system was compromised. It appeared to have been the work of Russian hackers.
The significance of this moment is obvious now, but it did not immediately cause alarm at the F.B.I. or the Justice Department.
Over the previous year, dozens of think tanks, universities and political organizations associated with both parties had fallen prey to Russian spear phishing — emails that tricked victims into clicking on malicious links. The D.N.C. intrusion was a concern, but no more than the others.
Months passed before the D.N.C. and the F.B.I. met to address the hacks. And it would take more than a year for the government to conclude that the Russian president, Vladimir V. Putin, had an audacious plan to steer the outcome of an American election.
Hillary Clinton checking her BlackBerry while on Capitol Hill in January 2009.
Chip Somodevilla / Getty Images
Despite moments of tension between leaders of the F.B.I. and the Justice Department, agents and prosecutors working on the case made progress. “The investigative team did a thorough job,” Mr. Giacalone said. “They left no stone unturned.”
They knew it would not be enough to prove that Mrs. Clinton was sloppy or careless. To bring charges, they needed evidence that she knowingly received classified information or set up her server for that purpose.
That was especially important after a deal the Justice Department had made with David H. Petraeus, the retired general and former director of the Central Intelligence Agency. Mr. Petraeus had passed classified information to his biographer, with whom he was having an affair, and the evidence was damning: He revealed the names of covert agents and other secrets, he was recorded saying that he knew it was wrong, and he lied to the F.B.I.
But over Mr. Comey’s objections, the Justice Department let Mr. Petraeus plead guilty in April 2015 to a misdemeanor count of mishandling classified information. Charging Mrs. Clinton with the same crime, without evidence of intent, would be difficult.
One nagging issue was that Mrs. Clinton had deleted an unknown number of emails from her early months at the State Department — before she installed the home server. Agents believed that those emails, sent from a BlackBerry account, might be their best hope of assessing Mrs. Clinton’s intentions when she moved to the server. If only they could find them.
In spring last year, Mr. Strzok, the counterintelligence supervisor, reported to Mr. Comey that Mrs. Clinton had clearly been careless, but agents and prosecutors agreed that they had no proof of intent. Agents had not yet interviewed Mrs. Clinton or her aides, but the outcome was coming into focus.
Nine months into the investigation, it became clear to Mr. Comey that Mrs. Clinton was almost certainly not going to face charges. He quietly began work on talking points, toying with the notion that, in the midst of a bitter presidential campaign, a Justice Department led by Democrats may not have the credibility to close the case and that he alone should explain that decision to the public.
A Suspicious Document
The J. Edgar Hoover Building, the headquarters of the F.B.I., in Washington.
Brendan Smialowski / Agence France-Presse — Getty Images
A document obtained by the F.B.I. reinforced that idea.
During Russia’s hacking campaign against the United States, intelligence agencies could peer, at times, into Russian networks and see what had been taken. Early last year, F.B.I. agents received a batch of hacked documents, and one caught their attention.
The document, which has been described as both a memo and an email, was written by a Democratic operative who expressed confidence that Ms. Lynch would keep the Clinton investigation from going too far, according to several former officials familiar with the document.
Read one way, it was standard Washington political chatter. Read another way, it suggested that a political operative might have insight into Ms. Lynch’s thinking.
Normally, when the F.B.I. recommends closing a case, the Justice Department agrees and nobody says anything. The consensus in both places was that the typical procedure would not suffice in this instance, but who would be the spokesman?
The document complicated that calculation, according to officials. If Ms. Lynch announced that the case was closed, and Russia leaked the document, Mr. Comey believed it would raise doubts about the independence of the investigation.
Mr. Comey sought advice from someone he has trusted for many years. He dispatched his deputy to meet with David Margolis, who had served at the Justice Department since the Johnson administration and who, at 76, was dubbed the Yoda of the department.
What exactly was said is not known. Mr. Margolis died of heart problems a few months later. But some time after that meeting, Mr. Comey began talking to his advisers about announcing the end of the Clinton investigation himself, according to a former official.
“When you looked at the totality of the situation, we were leaning toward: This is something that makes sense to be done alone,” said Mr. Steinbach, who would not confirm the existence of the Russian document.
Former Justice Department officials are deeply skeptical of this account. If Mr. Comey believed that Ms. Lynch were compromised, they say, why did he not seek her recusal? Mr. Comey never raised this issue with Ms. Lynch or the deputy attorney general, Sally Q. Yates, former officials said.
Mr. Comey’s defenders regard this as one of the untold stories of the Clinton investigation, one they say helps explain his decision-making. But former Justice Department officials say the F.B.I. never uncovered evidence tying Ms. Lynch to the document’s author, and are convinced that Mr. Comey wanted an excuse to put himself in the spotlight.
As the Clinton investigation headed into its final months, there were two very different ideas about how the case would end. Ms. Lynch and her advisers thought a short statement would suffice, probably on behalf of both the Justice Department and the F.B.I.
Mr. Comey was making his own plans.
A Hot Tarmac
Sky Harbor International Airport in Phoenix, where Ms. Lynch and former President Bill Clinton had an unscheduled meeting on the tarmac in June 2016.
Spencer Platt / Getty Images
A chance encounter set those plans in motion.
In late June, Ms. Lynch’s plane touched down at Phoenix Sky Harbor International Airport as part of her nationwide tour of police departments. Former President Bill Clinton was also in Phoenix that day, leaving from the same tarmac.
Ms. Lynch’s staff loaded into vans, leaving the attorney general and her husband on board. Mr. Clinton’s Secret Service agents mingled with her security team. When the former president learned who was on the plane, his aides say, he asked to say hello.
Mr. Clinton’s aides say he intended only to greet Ms. Lynch as she disembarked. But Ms. Lynch later told colleagues that the message she received — relayed from one security team to another — was that Mr. Clinton wanted to come aboard, and she agreed.
When Ms. Lynch’s staff members noticed Mr. Clinton boarding the plane, a press aide hurriedly called the Justice Department’s communications director, Melanie Newman, who said to break up the meeting immediately. A staff member rushed to stop it, but by the time the conversation ended, Mr. Clinton had been on the plane for about 20 minutes.
The meeting made the local news the next day and was soon the talk of Washington. Ms. Lynch said they had only exchanged pleasantries about golf and grandchildren, but Republicans called for her to recuse herself and appoint a special prosecutor.
Ms. Lynch said she would not step aside but would accept whatever career prosecutors and the F.B.I. recommended on the Clinton case — something she had planned to do all along.
Mr. Comey never suggested that she recuse herself. But at that moment, he knew for sure that when there was something to say about the case, he alone would say it.
Calling a Conference
Secret Service agents outside Mrs. Clinton’s home in Washington on July 2, 2016, the day she was interviewed there by federal agents.
Al Drago / The New York Times
Agents interviewed Mrs. Clinton for more than three and a half hours in Washington the next day, and the interview did not change the unanimous conclusion among agents and prosecutors that she should not be charged.
Two days later, on the morning of July 5, Mr. Comey called Ms. Lynch to say that he was about to hold a news conference. He did not tell her what he planned to say, and Ms. Lynch did not demand to know.
On short notice, the F.B.I. summoned reporters to its headquarters for the briefing.
A few blocks away, Mrs. Clinton was about to give a speech. At her campaign offices in Brooklyn, staff members hurried in front of televisions. And at the Justice Department and the F.B.I., prosecutors and agents watched anxiously.
“We were very much aware what was about to happen,” said Mr. Steinbach, who had taken over as the F.B.I.’s top national security official earlier that year. “This was going to be hotly contested.”
With a black binder in hand, Mr. Comey walked into a large room on the ground floor of the F.B.I.’s headquarters. Standing in front of two American flags and two royal-blue F.B.I. flags, he read from a script.
He said the F.B.I. had reviewed 30,000 emails and discovered 110 that contained classified information. He said computer hackers may have compromised Mrs. Clinton’s emails. And he criticized the State Department’s lax security culture and Mrs. Clinton directly.
“Any reasonable person in Secretary Clinton’s position” should have known better, Mr. Comey said. He called her “extremely careless.”
The criticism was so blistering that it sounded as if he were recommending criminal charges. Only in the final two minutes did Mr. Comey say that “no charges are appropriate in this case.”
Video The F.B.I. director, James B. Comey, said on Tuesday that the agency was not recommending charging Hillary Clinton in her use of a private email server while secretary of state.
Cliff Owen/Associated Press
The script had been edited and revised several times, former officials said. Mr. Strzok, Mr. Steinbach, lawyers and others debated every phrase. Speaking so openly about a closed case is rare, and the decision to do so was not unanimous, officials said. But the team ultimately agreed that there was an obligation to inform American voters.
“We didn’t want anyone to say, ‘If I just knew that, I wouldn’t have voted that way,’” Mr. Steinbach said. “You can argue that’s not the F.B.I.’s job, but there was no playbook for this. This is somebody who’s going to be president of the United States.”
Mr. Comey’s criticism — his description of her carelessness — was the most controversial part of the speech. Agents and prosecutors have been reprimanded for injecting their legal conclusions with personal opinions. But those close to Mr. Comey say he has no regrets.
By scolding Mrs. Clinton, Mr. Comey was speaking not only to voters but to his own agents. While they agreed that Mrs. Clinton should not face charges, many viewed her conduct as inexcusable. Mr. Comey’s remarks made clear that the F.B.I. did not approve.
Former agents and others close to Mr. Comey acknowledge that his reproach was also intended to insulate the F.B.I. from Republican criticism that it was too lenient toward a Democrat.
At the Justice Department, frustrated prosecutors said Mr. Comey should have consulted with them first. Mrs. Clinton’s supporters said that Mr. Comey’s condemnations seemed to make an oblique case for charging her, undermining the effect of his decision.
“He came up with a Rube Goldberg-type solution that caused him more problems than if he had just played it straight,” said Brian Fallon, the Clinton campaign press secretary and a former Justice Department spokesman.
Furious Republicans saw the legal cloud over Mrs. Clinton lifting and tore into Mr. Comey.
In the days after the announcement, Mr. Comey and Ms. Lynch each testified before Congress, with different results. Neither the F.B.I. nor the Justice Department normally gives Congress a fact-by-fact recounting of its investigations, and Ms. Lynch spent five hours avoiding doing so.
“I know that this is a frustrating exercise for you,” she told the House Judiciary Committee.
Mr. Comey discussed his decision to close the investigation and renewed his criticism of Mrs. Clinton.
By midsummer, as Mrs. Clinton was about to accept her party’s nomination for president, the F.B.I. director had seemingly succeeded in everything he had set out to do. The investigation was over well before the election. He had explained his decision to the public.
And with both parties angry at him, he had proved yet again that he was willing to speak his mind, regardless of the blowback. He seemed to have safely piloted the F.B.I. through the storm of a presidential election.
But as Mr. Comey moved past one tumultuous investigation, another was about to heat up.
Red Square in Moscow. The F.B.I. has been investigating whether members of the Trump campaign had ties to the Kremlin.
Vasily Maximov / Agence France-Presse — Getty Images
Days after Mr. Comey’s news conference, Carter Page, an American businessman, gave a speech in Moscow criticizing American foreign policy. Such a trip would typically be unremarkable, but Mr. Page had previously been under F.B.I. scrutiny years earlier, as he was believed to have been marked for recruitment by Russian spies. And he was now a foreign policy adviser to Mr. Trump.
Mr. Page has not said whom he met during his July visit to Moscow, describing them as “mostly scholars.” But the F.B.I. took notice. Mr. Page later traveled to Moscow again, raising new concerns among counterintelligence agents. A former senior American intelligence official said that Mr. Page met with a suspected intelligence officer on one of those trips and there was information that the Russians were still very interested in recruiting him.
Later that month, the website WikiLeaks began releasing hacked emails from the D.N.C. Roger J. Stone Jr., another Trump adviser, boasted publicly about his contact with WikiLeaks and suggested he had inside knowledge about forthcoming leaks. And Mr. Trump himself fueled the F.B.I.’s suspicions, showering Mr. Putin with praise and calling for more hacking of Mrs. Clinton’s emails.
“Russia, if you’re listening,” he said, “I hope you’ll be able to find the 30,000 emails that are missing.”
In late July, the F.B.I. opened an investigation into possible collusion between members of Mr. Trump’s campaign and Russian operatives. Besides Mr. Comey and a small team of agents, officials said, only a dozen or so people at the F.B.I. knew about the investigation. Mr. Strzok, just days removed from the Clinton case, was selected to supervise it.
It was a worrisome time at the F.B.I. Agents saw increased activity by Russian intelligence officers in the United States, and a former senior American intelligence official said there were attempts by Russian intelligence officers to talk to people involved in the campaign. Russian hackers had also been detected trying to break into voter registration systems, and intelligence intercepts indicated some sort of plan to interfere with the election.
In late August, Mr. Comey and his deputies were briefed on a provocative set of documents about purported dealings between shadowy Russian figures and Mr. Trump’s campaign. One report, filled with references to secret meetings, spoke ominously of Mr. Trump’s “compromising relationship with the Kremlin” and threats of “blackmail.”
The reports came from a former British intelligence agent named Christopher Steele, who was working as a private investigator hired by a firm working for a Trump opponent. He provided the documents to an F.B.I. contact in Europe on the same day as Mr. Comey’s news conference about Mrs. Clinton. It took weeks for this information to land with Mr. Strzok and his team.
Mr. Steele had been a covert agent for MI6 in Moscow, maintained deep ties with Russians and worked with the F.B.I., but his claims were largely unverified. It was increasingly clear at the F.B.I. that Russia was trying to interfere with the election.
As the F.B.I. plunged deeper into that investigation, Mr. Comey became convinced that the American public needed to understand the scope of the foreign interference and be “inoculated” against it.
He proposed writing an op-ed piece to appear in The Times or The Washington Post, and showed the White House a draft his staff had prepared. The article did not mention the investigation of the Trump campaign, but it laid out how Russia was trying to undermine the vote.
The president replied that going public would play right into Russia’s hands by sowing doubts about the election’s legitimacy. Mr. Trump was already saying the system was “rigged,” and if the Obama administration accused Russia of interference, Republicans could accuse the White House of stoking national security fears to help Mrs. Clinton.
Mr. Comey argued that he had unique credibility to call out the Russians and avoid that criticism. After all, he said, he had just chastised Mrs. Clinton at his news conference.
The White House decided it would be odd for Mr. Comey to make such an accusation on his own, in a newspaper, before American security agencies had produced a formal intelligence assessment. The op-ed idea was quashed. When the administration had something to say about Russia, it would do so in one voice, through the proper channels.
But John O. Brennan, the C.I.A. director, was so concerned about the Russian threat that he gave an unusual private briefing in the late summer to Harry Reid, then the Senate Democratic leader.
Top congressional officials had already received briefings on Russia’s meddling, but the one for Mr. Reid appears to have gone further. In a public letter to Mr. Comey several weeks later, Mr. Reid said that “it has become clear that you possess explosive information about close ties and coordination between Donald Trump, his top advisors, and the Russian government — a foreign interest openly hostile to the United States.”
Mr. Comey knew the investigation of the Trump campaign was just underway, and keeping with policy, he said nothing about it.
Mr. Comey testifying before the House Judiciary Committee in September.
Pablo Martinez Monsivais / Associated Press
Mr. Reid’s letter sparked frenzied speculation about what the F.B.I. was doing. At a congressional hearing in September, Representative Jerrold Nadler, Democrat of New York, pressed Mr. Comey for an explanation, citing his willingness to give details about his investigation of Mrs. Clinton.
“After you investigated Secretary Clinton, you made a decision to explain publicly who you interviewed and why,” Mr. Nadler said. “You also disclosed documents, including those from those interviews. Why shouldn’t the American people have the same level of information about your investigation with those associated with Mr. Trump?”
But Mr. Comey never considered disclosing the case. Doing so, he believed, would have undermined an active investigation and cast public suspicion on people the F.B.I. could not be sure were implicated.
“I’m not confirming that we’re investigating people associated with Mr. Trump,” Mr. Comey said to Mr. Nadler. “In the matter of the email investigation, it was our judgment — my judgment and the rest of the F.B.I.’s judgment — that those were exceptional circumstances.”
Even in classified briefings with House and Senate intelligence committee members, Mr. Comey repeatedly declined to answer questions about whether there was an investigation of the Trump campaign.
To Mr. Comey’s allies, the two investigations were totally different. One was closed when he spoke about it. The other was continuing, highly classified and in its earliest stages. Much of the debate over Mr. Comey’s actions over the last seven months can be distilled into whether people make that same distinction.
Just a few weeks later, in late September, Mr. Steele, the former British agent, finally heard back from his contact at the F.B.I. It had been months, but the agency wanted to see the material he had collected “right away,” according to a person with knowledge of the conversation. What prompted this message remains unclear.
Mr. Steele met his F.B.I. contact in Rome in early October, bringing a stack of new intelligence reports. One, dated Sept. 14, said that Mr. Putin was facing “fallout” over his apparent involvement in the D.N.C. hack and was receiving “conflicting advice” on what to do.
The agent said that, if Mr. Steele could get solid corroboration of his reports, the F.B.I. would pay him $50,000 for his efforts, according to two people familiar with the offer. Ultimately, he was not paid.
Around the same time, the F.B.I. began examining a mysterious data connection between Alfa Bank, one of Russia’s biggest, and a Trump Organization email server. Some private computer scientists said it could represent a secret link between the Trump Organization and Moscow.
Agents concluded that the computer activity, while odd, probably did not represent a covert channel.
But by fall, the gravity of the Russian effort to affect the presidential election had become clear.
The D.N.C. hack and others like it had once appeared to be standard Russian tactics to tarnish a Western democracy. After the WikiLeaks disclosures and subsequent leaks by a Russian group using the name DCLeaks, agents and analysts began to realize that Moscow was not just meddling. It was trying to tip the election away from Mrs. Clinton and toward Mr. Trump.
Mr. Comey and other senior administration officials met twice in the White House Situation Room in early October to again discuss a public statement about Russian meddling. But the roles were reversed: Susan Rice, the national security adviser, wanted to move ahead. Mr. Comey was less interested in being involved.
At their second meeting, Mr. Comey argued that it would look too political for the F.B.I. to comment so close to the election, according to several people in attendance. Officials in the room felt whiplashed. Two months earlier, Mr. Comey had been willing to put his name on a newspaper article; now he was refusing to sign on to an official assessment of the intelligence community.
Mr. Comey said that in the intervening time, Russian meddling had become the subject of news stories and a topic of national discussion. He felt it was no longer necessary for him to speak publicly about it. So when Jeh Johnson, the Homeland Security secretary, and James R. Clapper Jr., the national intelligence director, accused “Russia’s senior-most officials” on Oct. 7 of a cyber operation to disrupt the election, the F.B.I. was conspicuously silent.
That night, WikiLeaks began posting thousands of hacked emails from another source: the private email account of John D. Podesta, chairman of the Clinton campaign.
John D. Podesta, Mrs. Clinton’s campaign chairman, on board her campaign plane in September, a month before a large collection of his emails was posted online by WikiLeaks.
Doug Mills / The New York Times
The emails included embarrassing messages between campaign staff members and excerpts from Mrs. Clinton’s speeches to Wall Street. The disclosure further convinced the F.B.I. that it had initially misread Russia’s intentions.
Two days later, Mr. Podesta heard from the F.B.I. for the first time, he said in an interview.
“You may be aware that your emails have been hacked,” an agent told him.
Mr. Podesta laughed. The same agency that had so thoroughly investigated Mrs. Clinton, he said, seemed painfully slow at responding to Russian hacking.
“Yes,” he answered. “I’m aware.”
Supplementing the Record
Anthony D. Weiner, the former New York congressman, at the Democratic National Convention in Philadelphia in July.
Stephen Crowley / The New York Times
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.
Huma Abedin has long been one of of Mrs. Clinton’s closest confidants and served as a top aide during the campaign.
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.
Document | Letter to Congress From F.B.I. Director on Clinton Email Case 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.”
‘This Changes Everything’
Donald J. Trump at an Oct. 28 rally in Maine, where he said of the reopening of the Clinton email investigation, “This changes everything.”
Stephen Crowley / The New York Times
The Clinton team was outraged. Even at the F.B.I., agents who supported their high-profile director were stunned. They knew the letter would call into question the F.B.I.’s political independence.
Mr. Trump immediately mentioned it on the campaign trail. “As you might have heard,” Mr. Trump told supporters in Maine, “earlier today, the F.B.I. … ” The crowd interrupted with a roar. Everyone had heard.
Polls almost immediately showed Mrs. Clinton’s support declining. Presidential races nearly always tighten in the final days, but some political scientists reported a measurable “Comey effect.”
“This changes everything,” Mr. Trump said.
Mr. Comey explained in an email to his agents that Congress needed to be notified. “It would be misleading to the American people were we not to supplement the record,” he wrote.
But many agents were not satisfied.
At the Justice Department, career prosecutors and political appointees privately criticized not only Mr. Comey for sending the letter but also Ms. Lynch and Ms. Yates for not stopping him. Many saw the letter as the logical result of years of not reining him in.
Mr. Comey told Congress that he had no idea how long the email review would take, but Ms. Lynch promised every resource needed to complete it before Election Day.
At the F.B.I., the Clinton investigative team was reassembled, and the Justice Department obtained a warrant to read emails to or from Mrs. Clinton during her time at the State Department. As it turned out, only about 50,000 emails met those criteria, far fewer than anticipated, officials said, and the F.B.I. had already seen many of them.
Mr. Comey was again under fire. Former Justice Department officials from both parties wrote a Washington Post op-ed piece titled “James Comey Is Damaging Our Democracy.”
At a Justice Department memorial for Mr. Margolis, organizers removed all the chairs from the stage, avoiding the awkward scene of Mr. Comey sitting beside some of his sharpest critics.
Jamie S. Gorelick, a deputy attorney general during the Clinton administration, eulogized Mr. Margolis for unfailingly following the rules, even when facing unpopular options. Audience members heard it as a veiled critique of both Mr. Comey and Ms. Lynch.
On Nov. 5, three days before Election Day, Mr. Strzok and his team had 3,000 emails left to review. That night, they ordered pizza and dug in. At about 2 a.m., Mr. Strzok wrote an email to Mr. Comey and scheduled it to send at 6 a.m. They were finished.
A few hours later, Mr. Strzok and his team were back in Mr. Comey’s conference room for a final briefing: Only about 3,000 emails had been potentially work-related. A dozen or so email chains contained classified information, but the F.B.I. had already seen it.
And agents had found no emails from the BlackBerry server during the crucial period when Mrs. Clinton was at the State Department.
Nothing had changed what Mr. Comey had said in July.
That conclusion was met with a mixture of relief and angst. Everyone at the meeting knew that the question would quickly turn to whether Mr. Comey’s letter had been necessary.
That afternoon, Mr. Comey sent a second letter to Congress. “Based on our review,” he wrote, “we have not changed our conclusions.”
Mr. Comey appearing in March at a House Intelligence Committee hearing on Russian interference in the presidential election.
Zach Gibson / Getty Images
Mr. Comey did not vote on Election Day, records show, the first time he skipped a national election, according to friends. But the director of the F.B.I. was a central story line on every television station as Mr. Trump swept to an upset victory.
Many factors explained Mr. Trump’s success, but Mrs. Clinton blamed just one. “Our analysis is that Comey’s letter — raising doubts that were groundless, baseless, proven to be — stopped our momentum,” she told donors a few days after the election. She pointed to polling data showing that late-deciding voters chose Mr. Trump in unusually large numbers.
Even many Democrats believe that this analysis ignores other factors, but at the F.B.I., the accusation stung. Agents are used to criticism and second-guessing. Rarely has the agency been accused of political favoritism or, worse, tipping an election.
For all the attention on Mrs. Clinton’s emails, history is likely to see Russian influence as the more significant story of the 2016 election. Questions about Russian meddling and possible collusion have marred Mr. Trump’s first 100 days in the White House, cost him his national security adviser and triggered two congressional investigations. Despite Mr. Trump’s assertions that “Russia is fake news,” the White House has been unable to escape its shadow.
Mr. Comey has told friends that he has no regrets, about either the July news conference or the October letter or his handling of the Russia investigation. Confidants like Mr. Richman say he was constrained by circumstance while “navigating waters in which every move has political consequences.”
But officials and others close to him also acknowledge that Mr. Comey has been changed by the tumultuous year.
Early on Saturday, March 4, the president accused Mr. Obama on Twitter of illegally wiretapping Trump Tower in Manhattan. Mr. Comey believed the government should forcefully denounce that claim. But this time he took a different approach. He asked the Justice Department to correct the record. When officials there refused, Mr. Comey followed orders and said nothing publicly.
Video James B. Comey said that the agency is investigating Russian interference in the 2016 presidential election. Regarding President Trump’s tweets about alleged wiretapping by the Obama administration, Mr. Comey said the agency had “no information that supports those tweets.”
Eric Thayer for The New York Times
“Comey should say this on the record,” said Tommy Vietor, a National Security Council spokesman in the Obama administration. “He’s already shattered all norms about commenting on ongoing investigations.”
Mr. Richman sees no conflict, but rather “a consistent pattern of someone trying to act with independence and integrity, but within established channels.”
“His approach to the Russia investigation fits this pattern,” he added.
But perhaps the most telling sign that Mr. Comey may have had enough of being Washington’s Lone Ranger occurred last month before the House Intelligence Committee.
Early in the hearing, Mr. Comey acknowledged for the first time what had been widely reported: The F.B.I. was investigating members of the Trump campaign for possible collusion with Russia.
Yet the independent-minded F.B.I. director struck a collaborative tone. “I have been authorized by the Department of Justice to confirm,” he began, ushering in the next phase of his extraordinary moment in national politics.
Mr. Comey was still in the spotlight, but no longer alone.