Uber has selected the chief executive of Expedia, Dara Khosrowshahi, as its new leader, a surprising turn after board members considered two other stalwarts of industry, two people with direct knowledge of the matter said Sunday.

The move comes after a weekend of frantic meetings with two other final candidates, Meg Whitman, chief executive of Hewlett Packard Enterprises, and Jeff Immelt, the departing chief executive of GE. Immelt made it clear the job would not be his in a tweet Sunday. And a divided board shifted between Whitman and Khosrowshahi throughout the weekend, the people said, who spoke on condition of anonymity to discuss private meetings.

Khosrowshahi a Iranian-American who has run Expedia since 2005, was an unexpected and lesser-known choice; his interest in the position was largely kept secret until today. The agreement came together only in the last few days, such that even family members and friends close to Khosrowshahi were surprised by the news.

But within Silicon Valley, Khosrowshahi is well liked and respected. He has presided over a huge expansion of the online travel company to over 60 countries. Khosrowshahi is also a vocal critic of President Trump, particularly his travel ban against Muslim Americans.

People who know him said Khosrowshahi brings two assets to Uber. For one, he is considered even-keeled and low-key -- a sharp contrast to Uber's former chief executive and co-founder Travis Kalanick, who has been known to fly into fits of anger. (In one infamous episode that was caught on video earlier this year, Kalanick unloaded onto an Uber driver who criticized the company's wages).

"My whole life, anytime I've faced a high-pressure decision, my model for mature behavior has been, 'what would Dara do'? He's one of the humblest and most even-keeled people I know," said Ali Partovi, an entreprenuer and technology investor, who is Khosrowshahi's second cousin. The two went to primary school together in Iran.

Khosrowshahi's other asset is his skill as a dealmaker in the highly competitive market for online travel. He has expanded Expedia into an even larger online travel conglomerate by acquiring other consumer brands, such as bookings sites Travelocity and Orbitz, and home rental site Homeaway.

That instinct for honing in on competitors in related or similar businesses may serve Uber, which faces brutal competition from rival Lyft as well as other ride-sharing startups in developing countries, and the taxi industry itself, which in some cities have created copycat ride-sharing apps. Uber is already leveraging its network of drivers to expand into trucking and food delivery.Uber is the most highly-valued start-up Silicon Valley has produced over the past decade, and it is expected to move toward a massive public stock offering in the coming year or so.

Khosrowshahi will face a company in crisis. He is tasked with transforming the company's culture, while shoring up the company's business in the wake of lawsuits and competition, analysts say. Morale at Uber has plummeted in the wake of eight months of controversy, including reports of widespread discrimination and sexual harassment, lawsuits that threaten the company's future, a leadership vacuum, and the ouster of Kalanick.

The executive search has lasted all summer long and been marred by infighting among board members. After Kalanick was pushed out, he scrambled to find allies who would help him make a comeback, the people with knowledge of the matter said. That led one of the company's largest investors, Benchmark Capital, to sue Kalanick for breach of contract and fraud, arguing in court filings that Kalanick was seeking to entrench himself in the process for his own "selfish ends."

Kalanick fired back in his own legal filings, calling the Benchmark suit a baseless and "personal attack." Meanwhile, the board itself disagreed with the Benchmark suit, releasing a statement signed by all members except Benchmark representative Matt Cohler that it was "disappointed that a disagreement between shareholders" has resulted in litigation.