By Mike Colias

General Motors Co.'s shares jumped after the auto maker said it will help an electric-truck startup develop and manufacture new models, the latest example of investor infatuation with electric vehicles.

GM said Tuesday that in exchange for its services it would take an 11% stake in Nikola Corp., a would-be rival in the market for electrified pickups.

The deal marks the latest tie-up between traditional auto makers and upstarts trying to break into the car business, and also showcases GM's strategy of providing its electric-vehicle technology to others.

Shares of both stocks surged following the news. Nikola was up about 50% and GM up about 10% in early afternoon trading.

Under the deal, GM will provide electric batteries and fuel cells for Nikola's trucks, including its future Badger pickup truck, which GM will manufacture at a still-undisclosed location. GM will receive $2 billion in stock and a seat on Nikola's board.

The agreement is part of GM's strategy to monetize its electric-vehicle technology by supplying battery cells and other components to outside companies, which will generate revenue and help drive down costs, GM has said.

"This does validate our technology," GM Chief Executive Mary Barra told reporters on a conference call.

The deal comes as Wall Street has shown increasing enthusiasm about electric vehicles and the auto industry is moving quickly to add more plug-in models to meet tougher environmental regulations globally on tailpipe emissions.

GM has more than a dozen electric-vehicle models of its own in the works, including large pickup trucks that one day could compete with Nikola's Badger.

Overall, the Detroit auto maker is spending about $20 billion on electric and driverless-vehicle technology through mid-decade, including construction of a massive battery-cell factory in Ohio, being built with joint-venture partner LG Chem.

GM and other traditional auto makers have been largely left out of the recent investment binge on electrics, despite having technology and manufacturing scale that pure-electric rivals would struggle to match.

GM's stock price, while having recovered from this spring, when it closed factories due to Covid-19 concerns, was still down 25% over the past year at Friday's close and trades below its $33 IPO price from a decade ago.

By contrast, Tesla Inc., the market leader in battery-powered cars, has seen its stock jump fourfold this year. Several startups have drawn private money or had their valuations soar after going public.

Among them is Nikola, which went public in June via a reverse merger. Investors quickly drove up its value, and Nikola even briefly passed Ford Motor Co. in market value. Since then, the stock has pared most of those gains and closed Friday up 13.3% from its price at the close of the merger.

Rampant investor interest in the electric-vehicle market is reminiscent of activity around driverless cars a few years ago. That enthusiasm has cooled over the past two years as companies struggle to refine the technology and build business models around it.

GM's electric-vehicle strategy takes it in the direction of becoming more like an automotive supplier -- and they generally trade at higher price-to-earnings multiples, analyst Joseph Spak said in an investor note Tuesday. This spring, Honda Motor Co. said it would develop two electric vehicles using GM's technology. The two also are working together on fuel cells.

"GM is showing they can be a supplier of key technologies," Mr. Spak wrote. The downside, he said, is that GM is potentially helping to set up a future rival in the highly profitable truck market.

Nikola will be responsible for Badger sales and marketing and will retain the Nikola Badger brand. The Badger will be unveiled in December, and production is expected to start in late 2022, the company said.

The partnership with Nikola also will lead to the first broad commercial use of GM's hydrogen fuel-cell technology, which has been in the works for a few decades. Fuel cells mix oxygen with hydrogen from an on-board storage tank to create electrical power.

Helping drive investor interest in green vehicles are tougher tailpipe-emission standards in China and the European Union, which are prodding auto makers to add more fuel-efficient vehicles, including fully electric vehicles.

Advances in battery technology also have helped whittle down the high cost of electric vehicles, leading to more offerings from car companies and startups, although they remain more expensive than gas-powered cars.

The GM-Nikola pact is the latest example of startups and traditional car companies leaning on each other for technology and manufacturing help.

Ford Motor Co. last year agreed to invest $500 million in Michigan-based electric-truck maker Rivian Automotive. Ford in April said it scrapped plans for an electric SUV based on Rivian's technology but still is working on a future model.

Nikola Executive Chairman Trevor Milton said that having GM build its Badger pickup will save the startup the huge investment of buying or building a factory, for example.

Fisker Inc., a startup led by well-known Danish car designer Henrik Fisker, plans to outsource key parts like batteries and motors, and have others build the cars, competing instead on styling and brand cachet.

That outsourcing model contrasts with Tesla's vertically integrated approach. The Palo Alto, Calif., company makes its own battery cells and builds its own cars, including at a new factory in China. Tesla has another one under construction in Germany.

GM's deal with Nikola also gives the Detroit auto maker exposure to the long-haul trucking market, an area in which it doesn't now compete and one that Nikola is targeting with plans to build its own truck and develop fuel-cell infrastructure.

"That's a wide-open growth opportunity for us," Ms. Barra said.

Mr. Milton has said he has high hopes for the Badger, a planned pickup truck powered by both a lithium-ion battery and a hydrogen fuel cell that GM will engineer and manufacture under the new deal.

"My goal is to take the throne from the Ford F-150," Mr. Milton said in June. The F-150 pickup has been the top-selling model in the U.S. for many years.

--Michael Dabaie and Ben Foldy contributed to this article.

Write to Mike Colias at Mike.Colias@wsj.com

Corrections & Amplifications

This article was corrected at 5:45 p.m. ET because Fisker Inc. was incorrectly referred to as Fisker Automotive.