Tesla on Tuesday revealed plans to build a factory in Shanghai that would dramatically increase its notoriously constrained production capacity, with boss Elon Musk making his electric-car company's biggest overseas move yet just as a US-China trade battle heats up.

Musk said the plant, whose plans have been in the works for more than a year, would eventually have an annual production capacity of 500,000 cars, adding that he hoped it would be ‘completed very soon’.

Tesla has been looking to expand into global markets, plans that faced a potential threat from the intensifying trade frictions between Beijing and Washington, and US President Donald Trump's push to keep manufacturing jobs at home.

A joint announcement released by Shanghai's government said a preliminary agreement had been reached to build the plant in the commercial hub's Lingang district.

‘Shanghai will be the location for the first Gigafactory outside the United States,’ Musk was quoted saying.

‘It will be a state-of-the-art vehicle factory and a role model for sustainability. We hope it will be completed very soon.’

A Tesla spokesperson said ‘we expect construction to begin in the near future, after we get all the necessary approvals and permits.’

It would take roughly two years before production begins and then up to three more years before it reaches full production.

‘Tesla is deeply committed to the Chinese market, and we look forward to building even more cars for our customers here,’ the spokesperson said.

‘Today's announcement will not impact our US manufacturing operations, which continue to grow.’

Shanghai will provide full support to Tesla in a project combining manufacturing, research and development, and sales and aimed at super-charging electric-vehicle development in the city, the local government said.

Anticipation about a potential big Tesla investment had bubbled over the past year.

Tesla last month told shareholders that it was working with officials in Shanghai on establishing the plant, which would build electric cars and battery packs.

At the time, Musk told employees the electric carmaker was being reorganised to speed up production of Model 3 vehicles -- a key to profitability at the fast-growing firm.

Expectations of an impending announcement spiked after Bloomberg News earlier reported that Musk would travel to Shanghai on Tuesday.

The move could allow Tesla to avoid having Musk's expansion plans tripped up by mushrooming trade frictions.

China is both the world's largest car market and its biggest electric-vehicle market.

Domestic Chinese and foreign automakers have been racing to grab a piece of the sector, which is expected to continue to grow rapidly as the government pushes cleaner technologies partly to help combat chronic air pollution.