Elon Musk has signed a preliminary agreement with the Shanghai government to build a Tesla factory in China. According to reports, the upcoming China factory will be capable of manufacturing 500,000 vehicles per year, rivaling the output of Tesla’s main electric car plant in Fremont, CA.

Reports of Musk’s trip to China emerged yesterday after people familiar with the proceedings revealed that the Tesla CEO will be at an “event” in Shanghai on Tuesday, followed by a visit to Beijing sometime on Wednesday or Thursday. Few other details were provided about Musk’s trip to China, though pictures emerged on social media on Tuesday revealing that the Tesla CEO briefly stopped over in Thailand to drop off the minisub he and SpaceX engineers designed to help rescue the remaining 5 members of the stranded soccer team in the Tham Luang Nang Non cave complex. Reports of Musk’s signing of an agreement with the Shanghai government emerged soon after.

$TSLA CEO ⁦@elonmusk⁩ in Shanghai after signing agreement to build Tesla plant in China. pic.twitter.com/5qX85rQcPw — Phil LeBeau (@Lebeaucarnews) July 10, 2018

Tesla’s upcoming China factory is a key component to the company’s attempts at breaching the world’s largest market for electric vehicles. Amidst the ongoing trade war with the United States, China has opted to place steep tariffs on vehicles imported from abroad, including Tesla’s electric cars. With the new taxes in place, Tesla was forced to raise the prices of its Model S luxury sedan and its Model X SUV by 150,000 yuan ($22,647) to 250,000 yuan ($37,744).

With its own facility in the country, Tesla would be able to bypass China’s steep tariffs regardless of the presence of a trade war. In a previous statement during an earnings call last year, Musk remarked that a factory in China is pretty much the only way for Tesla to rival the price of local electric car manufacturers such as BYD. Musk further noted that a China facility, if and when it does get built, would likely be tasked with the production of the Model Y crossover SUV, a vehicle that is estimated to see a demand of up to 1 million units per year. Apart from the Model Y, Musk further noted that some of the Model 3 would probably be manufactured in the China facility as well.

Tesla was able to capitalize on China’s adjustments to its ownership laws that were implemented earlier this year. Prior to the US and China’s ongoing trade dispute, the Asian economic superpower removed ownership restrictions for facilities owned by foreign companies. This opened the way for Tesla to get an approval for a solely-owned facility in the country. Just recently, an image of Tesla’s approval for its China site from the Central Committee of the Communist Party of China emerged online, giving yet another sign that the facility is likely to break ground soon.

Tesla’s success in the world’s largest market for electric cars will likely be dependent on how the company could target the greater Chinese auto industry with its lower-priced vehicles. While the Model S and Model X are currently seen as status symbols for the successful and wealthy in the country, the luxury sedan and SUV nonetheless cater to the country’s upper class, which represents a much smaller market. With vehicles such as the Model Y and the Model 3 saturating China as well, Tesla could tap into the country’s ever-growing mainstream electric car market, which is on pace to hit a milestone of 1 million EVs sold in 2018.