BMW AG is betting that the future of the automotive industry is electric.

The German luxury-car maker announced a strategy shift on Wednesday that includes plans to invest in new technology to head off upstart competitors, such as the ride-sharing service Uber Inc. and Alphabet Inc.’s Google, which threaten to upend the global auto industry.

Last...