When Elon Musk unveiled the first Chinese-made Teslas in Shanghai in 2020, he went off script and started dancing. Peeling off his jacket, he flung it across the stage in a partial striptease.

Musk had reason to celebrate. A few years earlier, with Tesla on the brink of failure, he had bet on China, which offered cheap parts and capable workers — and which needed Tesla as an anchor to jump-start its fledgling electric vehicle industry.

For Chinese leaders, the prize was a Tesla factory on domestic soil. Musk would build one in Shanghai that would become a flagship, accounting for over half of Tesla’s global deliveries and the bulk of its profits.