STOCKHOLM/SAN FRANCISCO (Reuters) - Uber plans to buy up to 24,000 self-driving cars from Volvo, marking the transition of the U.S. firm from an app used to summon a taxi to the owner and operator of a fleet of cars.

The non-binding framework deal could offer San Francisco-based Uber a way to overcome setbacks at its autonomous driving division in Silicon Valley’s race to perfect self-driving systems.

Combining Volvo’s cars with Uber’s self-driving system builds on their nearly three-year relationship and comes as Uber’s autonomous driving unit has been hit by a lawsuit over trade secrets and the departure of top talent.

Automakers, ride-hailing firms and tech startups have been forging loose alliances in an effort to advance self-driving technology and claim a piece of what is expected to be a multi-billion-dollar business.

Geely-owned Volvo said in a statement on Monday it would provide Uber with its flagship XC90 SUVs equipped with autonomous technology as part of a non-exclusive deal from 2019 to 2021. A Volvo spokesman said it covered up to 24,000 cars.

The self-driving system that would be used in the Volvo cars -- which have yet to be built -- is under development by Uber’s Advanced Technologies Group.

Should Uber buy all 24,000 cars, it would be Volvo’s largest order by far and the biggest sale in the autonomous vehicle industry, giving Uber, which is losing more than $600 million a quarter, its first commercial fleet of cars.

Uber's Volvo XC90 self driving car is shown during a demonstration of self-driving automotive technology in Pittsburgh, Pennsylvania, U.S. September 13, 2016. REUTERS/Aaron Josefczyk

A new Volvo XC90 typically retails from a starting price of around $50,000.

Uber has been testing prototype Volvo cars for more than a year, with safety drivers in the front seat to intervene if the self-driving system fails, in Tempe, Arizona and Pittsburgh.

“Our goal was from day one to make investments into a vehicle that could be manufactured at scale,” Jeff Miller, Uber’s head of automotive alliances, said.

The cars, in theory, would be available through the Uber app to pick up passengers without a driver.

“It only becomes a commercial business when you can remove that vehicle operator from the equation,” Miller said.

No financial details were disclosed for the purchase, which would be a massive new investment for Uber and mark a change from Uber’s long-standing business model where contractor drivers buy or lease and maintain their own cars.

Miller said a small number of cars would be purchased using equity and others would be bought using debt financing.

The deal builds on a $300 million alliance Volvo announced with Uber last year focussed on collaborating on the design and financing of cars with self-driving systems, which require different steering and braking features and sensors.

“We get support developing this car,” Volvo Cars CEO Hakan Samuelsson said in an interview. “It’s also a big commercial deal.”

LYFT RIVALRY

Volvo, which has been under Chinese ownership since it was bought by Zhejiang Geely Holding Group from Ford in 2010, plans to make the SUVs at its Torslanda plant in western Sweden, and Samuelsson said they would be sold at roughly the same profit margin as Volvo sells through dealers.

Uber's rival Lyft has this year struck a research partnership with Alphabet Inc's GOOGL.O unit Waymo and secured deals with Ford Motor Co F.N and startups Nutonomy and Drive.ai to incorporate self-driving cars into its fleet.

Volvo’s agreement with Uber and Ford’s with Lyft show the pressure on automakers to avoid becoming obsolete in a world of increased automation, and on ride-services companies to start automating to cut driver costs and turn profits.

Volvo is one of Sweden’s biggest manufacturers by revenue, and has forecast a fourth straight year of record sales in 2017.