Tesla has been hinting at a Chinese plant since 2014 and now the automaker has finally confirmed one.

Following a meeting Tuesday with Chinese officials, Tesla CEO Elon Musk said Shanghai would become the first location for one of its so-called Gigafactories outside the United States.

The new plant will be operational in the next two years and at full capacity—expected in the next five years—will be able to build 500,000 cars per year, Tesla said.

Tesla CEO Elon Musk (r.) and Shanghai Mayor Ying Yong in Shanghai July 10, 2018

Tesla CEO Elon Musk (r.) and Shanghai Mayor Ying Yong in Shanghai July 10, 2018

Full approval for the plant from the Chinese government is yet to be received, though an initial agreement was signed Tuesday by Musk and Shanghai officials. The plant is expected to be constructed in a special free-trade zone where Tesla won't have to partner with a local automaker. There could be some tariffs initially, though Tesla would still benefit from lower costs made possible from improved logistics and access to the local supply chain.

Currently, all foreign automakers looking to build cars in China need to form a 50:50 joint venture with a local automaker, or face the same 25-percent tariff placed on imported cars, though the Chinese government is planning to ease this restriction by 2022. However, the 25-percent tariff has now been increased to 40 percent on U.S.-made cars as part of China's retaliation toward tariffs on various Chinese-made goods entering the U.S. announced by the Trump administration this month.

In response to the tariff increase, Tesla is increasing prices in China. Its Chinese website now lists the cheapest price for a Model S sedan at $128,500, up from $107,400 previously.

Tesla factory, Fremont, California

Tesla factory, Fremont, California

Tesla is not alone. BMW on Monday said it is also increasing prices in China and building more cars locally.

Tesla said the Chinese plant won't affect its production expansion plans in the U.S. The company currently has a vehicle plant in California and a battery plant in Nevada, and in May it said it was looking for a site for a new plant to handle production of its upcoming Model Y small SUV.

Beyond the tariffs, building cars in China is a heck of an opportunity for Tesla. China has implemented an aggressive low-emission strategy to combat its air quality problems, with the country aiming to reach seven million electric car sales by 2025. Currently, only 15 percent of Tesla’s sales come from China, despite the car market there being the world’s biggest.