SAN JOSE—Four decades ago, Japanese auto companies anticipated U.S. demand for fuel efficient cars and hit the market with vehicles that caught the Detroit Three by surprise, permanently altering the ranks of the biggest auto makers.

Today, the disrupters are bubbling up from California’s Silicon Valley. As software giants and startups rush to make smarter vehicles, established car makers are scrambling to avoid becoming victims of another sea change. The most common response: setting up research offices in the technology...