June 26 (Reuters) - Rivian Automotive surged 40% premarket on Wednesday after a $5 billion investment from Volkswagen offered the loss-making startup more firepower to roll out new models to attract consumers in a slowing electric-vehicle market.

The investment will also bolster Rivian's depleting cash reserves, move the startup closer to profitability and help it compete better in a market dominated by Tesla.

Under the deal, Rivian will form an equally controlled joint venture with Volkswagen to share EV architecture and software that would eventually be used by the German automaker's brands including Audi, Porsche and Lamborghini.

"It's a big vote of confidence in the EV maker's prospects," said Susannah Streeter, head of money and markets at Hargreaves Lansdown.

"Joining forces in this way may also help lower the cost-per-vehicle and bolster defenses against the growing might of Chinese EV makers."

Shares of Lucid also rose 5% as Citi analysts said the deal could spotlight the Saudi Arabia-backed luxury EV which has been open to licensing its technology and already has a tie-up with British automaker Aston Martin.

The increasing collaboration between EV makers and legacy automakers could, however, dent the businesses of companies such as Aptiv that have for years provided the auto industry with third-party software and technology.

Aptiv shares were down 5%, with Piper Sandler analysts saying the deal was a "red flag" for the company's strategy.

Rivian CEO RJ Scaringe told Reuters Volkswagen's investment would also provide the company the funding necessary to develop its less expensive Tesla Model Y-competitor R2 SUVs and its planned R3 crossovers.

"This is a core game changer for Rivian and changes the capital structure of the company looking ahead for the story and the Street's view at a key time," said Wedbush Securities analyst Dan Ives.

The company was set to add more than $4 billion to its market value of $12 billion, based on premarket movements. Its stock has lost nearly half its value this year after Rivian said in February it does not expect to produce more vehicles in 2024.

Still, D.A. Davidson analyst Michael Shlisky warned the funding could weigh on Rivian's share price as it was dilutive.

"We don't mean to throw cold water on the situation, but this funding isn't free, with $3 billion of dilutive equity investment over time, some of it at a discount to the current price," Shlisky said.

Rivian has also scrapped previous deals to make electric vehicles and commercial vans under separate joint ventures with Ford in 2021 and Mercedes Benz in 2022.

(Reporting by Akash Sriram in Bengaluru; Editing by Devika Syamnath)