Uber is teaming up with Toyota to build self-driving cars for its ride-hailing service.

Toyota, based in Japan, is also investing 500 million dollars (£387 million) in Uber as part of the alliance.

The deal aims to combine the best features from the two companies’ work on autonomous technology into cars that will be picking up Uber’s customers by 2021.

By the time that happens, Uber hopes to have completed an initial public offering of stock that will enrich a list of early investors that now includes Toyota.

Those investors have been pouring billions of dollars into Uber’s revolutionary ride-hailing service that still has not proven it can make money since its inception nearly a decade ago.

Uber is counting on self-driving cars to help it turn the financial corner by reducing the need to pay human drivers who arrive to pick up passengers in private vehicles summoned through a smartphone app.

By expanding into autonomous vehicles, Uber also hopes to ward off a looming competitive threat from another early investor, Google and its self-driving car spin-off Waymo, which is poised to launch its own ride-hailing service in Arizona before the end of this year.

“Our goal is to deploy the world’s safest self-driving cars on the Uber network, and this agreement is another significant step towards making that a reality,” said Uber chief executive Dara Khosrowshahi.

Meanwhile, Toyota is trying to evolve from a pure car maker into a “mobility company”, as are many of its industry peers, including General Motors and Ford in the US.

That crusade has prodded decades-old car makers such as Toyota and GM to invest in and partner with technology companies working on self-driving cars while also opening up their own research hubs in Silicon Valley.

Besides allowing them to lean on each other’s respective strengths, Toyota’s deal with San Francisco-based Uber also will help the two companies spread out the cost of designing and building the complex systems, which use computers, cameras, radar and laser sensors to guide the self-driving vehicles.

Uber is turning to Toyota for help in autonomous vehicles five months after one of its self-driving cars ran over and killed a pedestrian crossing a dark street in Tempe, Arizona.

The March 18 crash prompted Uber to temporarily suspend its work on its self-driving car program while conducting a safety evaluation.

Authorities determined the sensors on Uber’s self-driving car sensors spotted the pedestrian, 49-year-old Elaine Herzberg, but the vehicle’s automatic-braking function had been disabled in favour of a human backup driver.

Tempe police said the driver was distracted and streaming a television show before the crash.

Uber had little choice but to find a self-driving car partner after the collision that killed Ms Herzberg, said Navigant Research analyst Sam Abuelsamid.

“It’s going to be tough for them to build consumer trust in whatever it is they’re developing,” he said.

“I think that people will have a lot more trust in Toyota to do this the right way, to take due care and make sure everything is properly tested and evaluated.”

Uber’s expansion into self-driving cars suffered another setback last year after Waymo accused it of stealing its technology in an elaborate scheme.

The case went through one week of a high-profile trial before Uber agreed to pay Waymo 245 million dollars (£190 million) in stock to settle the allegations without acknowledging wrongdoing.