SHANGHAI—China has created the world’s largest electric-car market by sheer force of will, a giant bet on domestic production that’s leaving major foreign auto makers scrambling to keep up.

The government is funding its own manufacturers, luring domestic buyers with subsidies and building a vast charging-station network—while strong-arming its consumers by making sure buying an electric car is the only sure way to get license plates in crowded cities.

...