Tesla will open a factory for its Megapack batteries in Shanghai next year, as its CEO Elon Musk’s courtship of Chinese officials including President Xi Jinping appears to bear fruit.

Tesla has bought land for the Shanghai plant and is expected to start construction early next year, according to China’s state-run Xinhua News Agency.

Production will begin by 2024's fourth quarter and the factory will reportedly be capable of producing 10,000 Megapacks annually.

Tesla’s Megapack batteries provide energy storage for power utilities and companies, rather than for the electric vehicles that the US manufacturing giant is best known for.

Tesla already owns a huge electric vehicle factory in Shanghai that it reportedly wants to expand.

Tesla’s latest move will be a rare foray for a Western battery maker into China, a country that dominates the global battery industry.

Despite the strained relations between the US and China in recent years, Tesla chief Musk has fostered a close relationship with Chinese officials.

In a visit to the country in May he met with the foreign, commerce and industry ministers of China, as well as Zeng Yuqun, chairman of top battery supplier CATL.

Musk went one better last month, meeting Xi Jinping at a banquet when the Chinese President was on a visit to San Francisco.

Tesla later claimed that Xi had shown support for its development in China.

The cosy relationship even prompted US President Joe Biden to remark that Musk’s connections to other – sometimes less than friendly – countries are “worthy of being looked at.”

Those connections include India, where Tesla has reportedly proposed setting up a factory to roll out its “Powerwall” home energy storage system following a Musk meeting with Prime Minister Narendra Modi earlier this year.