Facebook chief executive Mark Zuckerberg endured an hours-long grilling by dozens of U.S. senators Tuesday during which he repeatedly apologized and promised privacy reforms but also pointedly defended his company against the threat of new legislation.

Zuckerberg invoked Facebook’s unlikely journey – from a tiny start-up he co-founded in his Harvard dorm room 14 years ago to a social media behemoth – in explaining Facebook’s frequent privacy missteps and its failure to spot and defeat Russia’s aggressive campaign to manipulate American voters in 2016 and beyond.

“If Facebook and other online companies will not or cannot fix these privacy invasions, then we will,” said Sen. Bill Nelson, Fla., the highest-ranking Democrat on the Commerce Committee.

But for more than four hours, there was no flash point or loss of composure for Zuckerberg, who was appearing in his first congressional hearing after avoiding such scrutiny for years. His steadiness in the face of tough questioning helped quell the air of crisis that surrounded not just Facebook but also Silicon Valley in general, where collecting user data is essential to many businesses.

Facebook’s stock price, sagging since last month’s revelations about how the political consultancy Cambridge Analytica improperly gained access to personal information on 87 million Facebook users, rose during his testimony to end up 4.5 percent for the day, outperforming a generally strong market.

Still, the issues raised in the hearing strike at deep problems for one of the most highflying technology companies. Gallup found in a poll released this week that 43 percent of Americans are “very concerned” about Facebook’s invasions of privacy – an increase of 13 percentage points since 2011, when Gallup conducted a similar poll.

Zuckerberg, who traded his trademark T-shirt and hoodie for the standard Capitol Hill garb of a dark suit and tie, had holed up with advisers in Washington over the weekend to prepare for the hearing. His tone was one of practiced and patient contrition as he described the company’s recent failings and efforts to remedy them.

“It’s clear now that we didn’t do enough to prevent these tools from being used for harm as well,” Zuckerberg said. “And that goes for fake news, foreign interference in elections and hate speech, as well as developers and data privacy.”

Zuckerberg took responsibility for the missteps. “We didn’t take a broad enough view of our responsibility, and that was a big mistake. And it was my mistake, and I’m sorry. I started Facebook, I run it, and I’m responsible for what happens here.”

Yet there was a broader context to the hearing, coming amid rising complaints about how a range of leading tech companies profit from virtually unfettered access to user data – something increasingly restricted in Europe and elsewhere in the world.

In other comments, Zuckerberg singled out Facebook’s inability to identify and combat Russian disinformation efforts as one of his “biggest regrets” and added, “One of my top priorities in 2018 is getting this right.”

He also confirmed for the second time since February that Facebook officials have been interviewed by investigators for special counsel Robert Mueller III, who have been looking into Russia’s role in influencing the 2016 election.

The exchanges between the 33-year-old billionaire and lawmakers were often tense. But Zuckerberg also caused spectators to laugh when he turned down an opportunity for a break, saying he could keep answering questions for 15 more minutes before stopping.

Zuckerberg’s acknowledgments of responsibility punctuated an extraordinary shift in tone for him and the company. He has strained in recent weeks to convince lawmakers, users and regulators that Facebook is determined to deliver meaningful change after repeated privacy controversies.

The House Energy and Commerce Committee has its own hearing scheduled for Wednesday morning.

Several senators asked for detailed answers about how private, third-party companies gained access to personal data on tens of millions of Americans.

Others questioned whether the very business model of Facebook – which makes money by selling online advertisements based on what it learns about users on the platform – was flawed.

“Mr. Zuckerberg, in many ways, you and the company that you’ve created, the story you’ve created, represent the American Dream,” said Sen. John Thune, R-S.D., chairman of the Commerce Committee. “Many are incredibly inspired by what you’ve done. At the same time, you have an obligation, and it’s up to you, to ensure that dream doesn’t become a privacy nightmare.”

In one sharp exchange, Sen. Lindsey Graham, R-S.C., asked Zuckerberg whether he agreed with a 2016 memo written by Facebook Vice President Andrew Bosworth, a longtime Zuckerberg deputy. In the memo, Bosworth appeared to suggest that bad outcomes – including bullying and even death – were unfortunate but inevitable side effects of the company’s mission to connect the world.

At first, Zuckerberg tried to sidestep the question, saying that most people at the company didn’t agree with the memo. Graham shot back, saying, “If somebody who said this worked for me, I’d fire him.”

Zuckerberg replied that he believes it’s important to create a work environment where people feel free to speak their minds.

Sen. Richard Blumenthal, D-Conn., said later in the hearing, “We’ve seen the apology tours before. . . . I don’t see how you can change your business model unless there are different rules of the road.”

Facebook’s recent controversies have generated a rare level of bipartisan consensus about the power of social media to twist public discourse and jeopardize the functioning of democracies. Many lawmakers – Republicans and Democrats – are calling for new legislation, fines or greater regulation.

In one of the most contentious exchanges of the afternoon, Sen. Ted Cruz, R-Texas, accused Facebook of a “pervasive pattern of political bias” against conservatives. Zuckerberg disputed the allegation, saying he worked to prevent such bias despite acknowledging that Silicon Valley was “an extremely left-leaning place.”

Another pointed exchange took place when Sen. Richard Durbin, D-Ill., asked Zuckerberg what hotel he stayed at Monday night and the names of anyone he messaged this week. Zuckerberg, appearing amused by the question, declined to answer.

Al Drago, Bloomberg

Cutouts of Facebook’s Mark Zuckerberg are displayed near the Capitol in Washington, D.C., on April 10, 2018.

Durbin shot back, “I think that may be what this is all about: your right to privacy, the limits of your right to privacy and how much you give away in modern America in the name of quote, ‘connecting people around the world.’ ”

The air of expectation around the hearing was remarkable, even by the standards of televised Capitol Hill political theater. Spectators lined up along the walls of the Hart Senate Office Building hours in advance, snaking from the 138-seat hearing room on the second floor.

To account for the expanded roster of members attending the hearing – amounting to almost half the Senate – congressional staffers added an extra table to the dais.

One attendee arrived dressed as a Russian troll – in a scout-like uniform with fake troll hair and a scarf resembling a Russian flag. Three others in the crowd rose before Zuckerberg entered to protest. Wearing neon-colored, oversize glasses that read “stop spying,” they displayed poster boards – labeled Code Pink – with slogans like”stop corporate spying” and “protect our privacy” and “Like us on Facebook.”

Outside, on the Capitol’s lawn, 100 life-size cutouts of Zuckerberg sported T-shirts reading, “fix fakebook” – the work of an advocacy group, Avaaz, calling attention to how fake accounts spread disinformation on the social network.

Facebook has been reeling since the November 2016 election, during which phony news reports spread widely on its platform and Russian operatives mounted an ambitious campaign to divide American voters, damage Democrat Hillary Clinton and bolster the chances of Republican Donald Trump.

Facebook appeared to be recovering from those controversies until last month’s revelations about Cambridge Analytica. Facebook last week acknowledged a separate problem in which “malicious actors” were able to identify and collect data on Facebook users on such a massive scale that most of the company’s 2.2 billion users were affected.

As the company has mobilized to quell rising political opposition, Facebook also has wrestled government investigations in the United States and Europe. The Federal Trade Commission is investigating potential violations of a 2011 consent decree over privacy policy at Facebook that could lead to record fines for the company.

Long before the results from the 2018 election were known, Republicans — especially those running for statewide office — faced daunting electoral challenges. Now, according to political insiders interviewed by The Denver Post this week, the situation is more dire for Colorado’s GOP.