General Motors Co. is raising its investment in electric vehicles—the second boost in recent months—and pushing deeper into battery production, making it the latest global auto maker to accelerate its transition to plug-in cars.

The company also raised its guidance for pretax profit excluding one-time items for the first half of this year, to between $8.5 billion and $9.5 billion, compared with its prior forecast of $5.5 billion. GM attributed the improved outlook to continued strength in the U.S. vehicle market and progress combating the semiconductor shortage that has stymied global vehicle production this year.

GM said Wednesday that it will spend $35 billion on electric and autonomous vehicles through 2025, about 30% higher than a target set last November. The increase reflects plans to add two more battery factories in the U.S., joining a plant under construction in Ohio and another slated for Tennessee.

Chief Executive Mary Barra said GM perceives momentum building for electric-vehicle adoption in the U.S.

Chief Executive Mary Barra said GM perceives momentum building for electric-vehicle adoption in the U.S.

Photo: rebecca cook/Reuters

Chief Executive Mary Barra said GM is moving faster because the company perceives momentum building for electric-vehicle adoption in the U.S. and has seen a positive response to the future models it has shown.

GM and other car companies have been steadily raising their bets on electric cars in the face of stiffening tailpipe-emissions regulations globally. The moves, which at times seem like dueling declarations, also have attracted investors eager to tap the growth potential of battery-powered vehicles.

Two weeks ago, GM rival Ford Motor Co. said it would increase its investment in electric-vehicle spending through mid-decade by about one-third, to $30 billion by 2025. That sum includes some money spent in recent years. Ford also said Wednesday that it expects half of vehicle sales from its luxury Lincoln brand to be fully electric within four years.

Meanwhile, Volkswagen AG is spending about $40 billion through mid-decade on electric vehicles.

In the past year, the amount of planned spending by car companies on electric vehicles has surged 41%, according to consulting firm AlixPartners LLP.

GM’s $35 billion spending target disclosed Wednesday is 75% higher than the level it cited in March 2020, when it first outlined its electric-vehicle investment strategy in detail.

“The investment has reached an inflection point,” said Mark Wakefield, co-leader of AlixPartners’ automotive practice.

While electric cars are simpler to produce than gas-powered models, auto makers are spending huge sums of money to increase battery production and bring other components in-house, such as electric motors.

Demand for lithium is expected to outpace global supply as consumers switch to battery-powered vehicles. With China currently leading in processing of the vital raw material, the U.S. government is looking to boost domestic production. Photo illustration: Carlos Waters/WSJ The Wall Street Journal Interactive Edition

For example, VW said it plans to build six battery factories in Europe alone. Ford said last month that it could need 10 battery factories globally by the end of the decade.

The spending increase coincides with President Biden’s push for federal investment in battery manufacturing and charging stations to support U.S. electric-vehicle production. The administration has called for $174 billion in electric-vehicle related spending, which includes fresh federal tax credits for purchasing battery-powered vehicles and commercial trucks.

Auto makers are pouring money into a technology that today represents only a sliver of vehicle sales globally. Electric vehicles accounted for about 5% of sales across the three major regions of Europe, China and the U.S. in 2020, according to research firm IHS Markit.

GM is funding its electric investment through profits from sales of its gas-powered models, including large pickup trucks and sport-utility vehicles, the company’s biggest profit generators.

GM and other auto makers have seen profits surge since last summer, as demand for new cars rebounded from a pandemic-related drop. They also are taking advantage of record pricing, as inventory at U.S. dealerships shrivels because of lower production from the computer-chip shortage.

GM said early this month that first-half pretax profit would be significantly better than earlier forecasts, partly because it was able to pull ahead chip deliveries that had been scheduled for the third quarter. On Wednesday, the company said the second half of the year would “continue to be complex and fluid.”

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