Uber has chosen Dara Khosrowshahi, the chief executive of travel company Expedia, to be its new boss, ending a contentious search that has been marred by boardroom spats and leaks.

The announcement, made on Sunday, comes as the ride-hailing service fights allegations of sexism and racism that led to the ousting of its founder, Travis Kalanick.

Khosrowshahi, a 48-year-old Iranian American who has led Expedia for 12 years, was a surprise appointment who beat Meg Whitman, the chief executive of HP Enterprise, and Jeff Immelt, the former CEO of General Electric, for the job.

The Expedia CEO has been critical of Donald Trump, tweeting in the wake of his Charlottesville remarks: “I keep waiting for the moment when our Prez will rise to the expectations of his office and he fails, repeatedly.”

Earlier on Sunday, Immelt said via Twitter that he had “decided not to pursue a leadership position at Uber”, while expressing “immense respect” for the cab-hailing company and its founders.

Immelt stepped down as CEO at GE this year after 16 years running the industrial conglomerate. The 61-year-old did not say why he had pulled out, but the New York Times said that he would not likely have received enough votes from the Uber board to edge ahead of rival candidates.

Uber’s eight-member board met over the weekend to decide on a new CEO, the New York Times said. The shortlist of candidates had narrowed to three people – Whitman, Immelt and Khosrowshahi.

Whitman, 61, had previously said she planned to stay at HP and described speculation over her departure from the IT services group as a “distraction”. She tweeted last week: “We have a lot of work still to do at HPE.”

Uber had been searching for an experienced executive to fill the vacuum left at the top by the departure of co-founder Kalanick in June, and to restore confidence in the business following months of chaos.

Khosrowshahi will have to reform the company’s workplace culture following accusations of sexual discrimination and harassment, recruit new executives including a chief financial officer and chief operating officer, and deal with numerous legal wrangles. They include an intellectual property dispute with Waymo, Google’s self-driving car spinoff.

Kalanick resigned in June following pressure from investors, just one week after taking an indefinite leave of absence. That leave of absence was not enough for a group of investors who own more than a quarter of Uber’s stock and account for about 40% of voting shares, giving them enough leverage to force out Kalanick when they demanded that he quite the role.

The venture capitalist David Bonderman resigned from Uber’s board of directors in June after making a sexist comment at the all-staff meeting where the Holder report’s recommendations were presented. At least 20 employees were fired over incidents of harassment, retaliation, discrimination and bullying, dozens more were disciplined and a number of complaints remain under investigation by Holder’s law firm, Perkins Coie.

Kalanick came under fire for his leadership style when Bloomberg released a video of him berating an Uber driver after the driver had complained about the difficulty making a living with Uber’s falling pay rates. Kalanick apologised for his behaviour in a statement that conceded he needed “leadership help”, and he announced his intention to hire a chief operating officer to assist him in the management of the company.