Big oil companies and giant auto makers are teaming up to preserve the internal combustion engine, as tough regulation and electric vehicles put the car industry’s century-old technology at risk. Their secret weapon: high-tech engine oil.

Exxon Mobil Corp., BP PLC, Royal Dutch Shell PLC and other oil companies are spending millions of dollars a year in concert with auto makers such as Ford Motor Co. and Fiat Chrysler Automobiles NV to create the next generation of super-slick engine lubricants. They are betting that the new,...