They found signs as early as spring 2016 that Russian hackers were poking around the Facebook accounts of people linked to American presidential campaigns. Months later, they saw Russian-controlled accounts sharing information from hacked Democratic emails with reporters. Facebook accumulated evidence of Russian activity for over a year before executives opted to share what they knew with the public — and even their own board of directors.

The company feared Trump supporters

In 2015, when the presidential candidate Donald J. Trump called for a ban of Muslim immigrants, Facebook employees and outside critics called on the company to punish Mr. Trump. Mr. Zuckerberg considered it — asking subordinates whether Mr. Trump had violated the company’s rules and whether his account should be suspended or the post removed.

But while Mr. Zuckerberg was personally offended, he deferred to subordinates who warned that penalizing Mr. Trump would set off a damaging backlash among Republicans.

Facebook hired Senator Mark Warner’s former chief of staff to lobby him; Ms. Sandberg personally called Senator Amy Klobuchar to complain about her criticism. The company also deployed a public relations firm to push negative stories about its political critics and cast blame on companies like Google.

Those efforts included depicting the billionaire liberal donor George Soros as the force behind a broad anti-Facebook movement, and publishing stories praising Facebook and criticizing Google and Apple on a conservative news site.

Cambridge Analytica raised the stakes

Facebook faced worldwide outrage in March after The Times, The Observer of London and The Guardian published a joint investigation into how user data had been appropriated by Cambridge Analytica to profile American voters. But inside Facebook, executives thought they could contain the damage. The company installed a new chief of American lobbying to help quell the bipartisan anger in Congress, and it quietly shelved an internal communications campaign, called “We Get It,” meant to assure employees that the company was committed to getting back on track in 2018.

Some criticisms hurt more than others

Sensing Facebook’s vulnerability, some rival tech firms in Silicon Valley sought to use the outcry to promote their own brands. After Tim Cook, Apple’s chief executive, quipped in an interview that his company did not traffic in personal data, Mr. Zuckerbergordered his management team to use only Android phones. After all, he reasoned, the operating system had far more users than Apple’s.

Facebook still has friends

Washington’s senior Democrat, Senator Chuck Schumer of New York, raised more money from Facebook employees than any other member of Congress during the 2016 election cycle — and he was there when the company needed him.

This past summer, as Facebook’s troubles mounted, Mr. Schumer confronted Mr. Warner, who by then had emerged as Facebook’s most insistent inquisitor in Congress. Back off, Mr. Schumer told Mr. Warner, and look for ways to work with Facebook, not vilify it. Lobbyists for Facebook — which also employs Mr. Schumer’s daughter — were kept abreast of Mr. Schumer’s efforts.