Steven Penkevich spent 36 years at Ford Motor Co. F -0.65% as part of an army of Detroit engineers who perfected the internal combustion engine, a technology dating back to the dawn of the automobile era. He developed gasoline engines for family sedans as well as thunderous Nascar racing machines.

By last year, though, the excitement was gone. His projects were no longer about advancing the engine, just nursing along existing technology. All the buzz had shifted to electric vehicles. In December, Mr. Penkevich took early retirement at age 59 “It got to feel like you’re on a maintenance crew,” he said.

For more than a century, auto makers continually honed their gas and diesel engines, sparring over which had greater power, better fuel efficiency, more durability or delivered a smoother ride.

Now, some of the world’s biggest car companies are sending the combustion engine to the scrap heap and are pouring billions of dollars into electric motors and battery factories. Instead of powertrain specialists, they are hiring thousands of software engineers and battery experts.

The transition is hardly noticeable yet on showroom floors. But it is upending the automotive workplace, from the engineering ranks and supply chain to the factory floor. Experts like Mr. Penkevich are retiring early or being laid off. Parts makers that for generations have made the same pieces for engines and transmissions are jockeying to supply electrical components.

Unions in the U.S. and Europe, fearing a steep loss of jobs tied to making engines and transmissions, are appealing to governments to help protect their members. The United Auto Workers has warned that the move to electric vehicles, which the union has said require fewer parts and roughly 30% less manpower to produce, could jeopardize tens of thousands of U.S. jobs.

“It’s been a fun ride,” said engineer Dave Lancaster, who spent 40 years working in engine development at General Motors Co. GM -1.26% “But I think we’re coming into the homestretch for the conventional engine.”

Auto executives have concluded, to varying degrees, that they can’t meet tougher tailpipe-emissions rules globally by continuing to improve gas or diesel engines. And they have watched the stocks of electric-car maker Tesla Inc. TSLA -0.91% and other upstart companies soar.

Today, electric cars account for less than 5% of global vehicle sales. Mercedes-Benz AG said Thursday it is gearing up to go all-electric by the end of the decadeGeneral Motors Co. has said it aims to convert nearly its entire vehicle lineup to fully electric by 2035. Executives have said they don’t intend to develop any new gas engines. “I don’t know where to spend money on them anymore,” GM President Mark Reuss said last year.

Developing a new gas engine can cost as much as $1 billion and involves hundreds of suppliers. Over the past several decades, auto makers in most years rolled out between 20 and 70 new engines globally, according to research firm IHS Markit. That number will fall below 10 this year, and then essentially go to zero, the research firm said.

A century ago, electric cars vied with internal-combustion and even steam-powered ones to become the powertrain of choice for cars. At one point, cars powered by electric motors outnumbered those running on gasoline in the U.S.

But by the early 1900s, innovations such as the electric starter had improved gas engines, and electricity generation outside big cities was scarce, said John Heitmann, a historian at the University of Dayton in Ohio. Gasoline engines eventually won out, in part because of Henry Ford’s assembly-line innovations.

Over the decades, attributes such as engine size, shape and how it was cooled became the stuff of legend among car enthusiasts. Powertrain engineers enjoyed celebrity status in auto circles. Engines such as Jaguar’s straight-six and Chevrolet’s small-block V8 became powerful brands, and car companies built marketing campaigns around their motors.