Tesla CEO Elon Musk’s visit to China this week paid off.

He finalized an agreement to build a combined car and battery factory in Shanghai designed to produce 500,000 cars a year. Doing so will give Tesla expanded global production capability, as well as tariff-free supply in the world’s largest electric-vehicle market.

China has forced foreign automakers to partner with a local company in order to enter the market. Tesla, though, will be able to operate independently thanks to a thaw in Beijing’s stance on foreign automobile industry investment.

Producing cars in China will insulate Tesla from the import tariffs that China issued last week in response to those created by the Trump administration. Those have already prompted Tesla to raise its prices for Chinese consumers (more on that below).

The Shanghai agreement left two big outstanding questions. One is where the money-burning, cash-strapped Tesla will get the capital to build the plant.

The other is which manufacturer Musk will pick to supply the cells that Tesla turns into battery packs.

When Nikkei Asian Review reached out to Panasonic, Tesla’s battery partner at its Nevada Gigafactory, the company said, “We have not received any specific production requests.”

Panasonic would be open to working with Tesla in Shanghai, Bloomberg reported.

The factory will alter the geopolitical terrain of battery production. Ever since Sony commercialized lithium-ion production back in 1991, the energy storage industry has looked to Japan and South Korean for top-tier batteries.

Recently, though, leading manufacturers LG Chem and Samsung SDI have sold more of their product into their domestic market in South Korea, said GTM Research analyst Mitalee Gupta, who studies energy storage supply chains.

“That opens the door to Chinese companies like BYD and CATL to tap into the international markets for people who can’t access the Korean market,” she said. “These are not a compromise to vendors; they actually think the technology is competing head to head.”

Both BYD and CATL are on track to cross 50 gigawatt-hours of cell manufacturing capacity by 2020, she added.

Bye-bye tax credit

Tesla buyers have benefited from a $7,500 federal tax credit, but that’s going away.

The law granting that credit triggers a drawdown when a company passes 200,000 electric vehicle sales, which Tesla did this month. The idea was to boost the initial wave of EVs by making them more affordable, but to withdraw taxpayer support once they hit a certain threshold.

The full $7,500 remains for the rest of the year. Then it will halve to $3,750 for the first half of 2019 and halve again for the second half.

Many states provide their own incentives up to a few thousand dollars; Tesla lists them here.

The good news for Tesla is that milestone means it’s sold a lot of cars. Ironically, notes Jack Stewart at Wired, the timing means most of this tax credit will go to customers who could afford the luxury prices of the Model S and Model X. By the time the more accessibly priced Model 3 becomes widely available, middle-class customers will have a shrunken benefit.

Opponents of electric vehicles subsidies cite this dynamic as an injustice — taxpayers are subsidizing rich people’s super cars. But the policy goal was to make EVs more accessible, and that meant wealthier people investing and benefiting early so that costs could come down for everyone else.

Tesla has yet to deliver on the promise of affordable, mass-market electric vehicles. The success of the tax credit as a policy decision will hinge on whether Tesla and its peers get there eventually.

Price hikes in China

China was already charging a 25 percent tariff on imported cars. The government was planning to bring that down, but instead raised it to 40 percent for U.S. built vehicles in retaliation to the Trump administration's tariffs that went into effect last week.

That means Teslas, which already cost more in China, just got more expensive. Tesla raised prices on its Model S and Model X by amounts between $20,000 and $30,000, depending on the model.

That makes the luxury cars even more luxurious, and adds urgency to the company’s decision to build a factory in Shanghai.

There’s no guarantee that the trade war will still be raging in a few years when the factory begins production, but local manufacturing hedges against future trade barriers. It also simplifies the supply chain, Gupta pointed out.

Currently, battery cells made in Asia get shipped to the U.S. to end up in battery packs. Once installed in a Tesla vehicle, it gets shipped back to Asia to reach customers there. Putting the factory closer to the market will shorten that process and potentially avoid logistics delays.