In a heavy blow to president Donald Trump and his protectionist "America First" sloganeering, Tesla, Inc has signed a deal to manufacture 500,000 of its electric sedans at a new and massive facility to rise in Shanghai called "Gigafactory 3." 

Tesla CEO and founder Elon Musk said the move to China was made to avoid a 25 percent tariff on US-made cars imposed by China in retaliation for Trump's 10 percent tariff on imported aluminum and 25 percent tariff on imported steel now being collected by the U.S.

On Monday, Tesla increased prices on its Model X and S by about 20 percent in China, becoming the first car maker to do so in the world's largest car market. The hike was made in response to the trade war between China and the U.S.

Tesla is the largest maker of electric cars in the United States. It produces its Model S, X and 3 all-electric vehicles at a huge facility in Fremont, California. Last May, however, Trump admitted the Fremont factory was "jammed to the gills" producing all three models. Musk then said Tesla will announce locations for two new Tesla factories as early as this summer.

The first of these locations is China. Tesla has since confirmed the move to China and the building of Gigafactory 3.

On Tuesday, Musk signed an agreement with officials of the Shanghai municipal government to build a factory capable of producing 500,000 electric vehicles per year. Shanghai officials said the Tesla factory is the largest foreign-funded manufacturing project in Shanghai's history.

Analysts said a Chinese factory will help Tesla avoid the new import taxes since the firm can now make its cars in China, and then sell the cars directly to Chinese consumers or to those in other Asian countries.

"Last year, we announced that we were working with the Shanghai municipal government to explore the possibility of establishing a factory in the region to serve the Chinese market," said Tesla in a statement. "Today, we have signed a Cooperative Agreement for Tesla to start building Gigafactory 3, a new electric vehicle manufacturing facility in Shanghai."

Tesla noted it will take some two years until before it starts producing vehicles, and another two to three years for the factory to ramp up to producing 500,000 vehicles per year.

Now, the only thing Tesla has to do is to wait for the inevitable Trump tweets blasting it for its decision to create jobs in China and not the U.S.