TOKYO — Japanese automakers Toyota Motor Corp. and Mazda Motor Corp. plan to spend $1.6 billion to build a joint-venture auto manufacturing plant in the U.S. – a move that will create up to 4,000 jobs, both sides said Friday.

The plant will have an annual production capacity of about 300,000 vehicles and will produce Toyota Corollas for the North American market. Mazda will make crossover models there that it plans to introduce to that market, the companies said.

Toyota and Mazda are forming a capital alliance and splitting the cost for the plant equally. It is expected to begin operations by 2021.

After reassessing the market, Toyota changed its plan to make Corollas at a plant in Guanajuato, Mexico, now under construction, and instead will produce Tacoma pickups there, Toyota President Akio Toyoda said.

President Trump had criticized Toyota for taking auto production and jobs to Mexico. With the investment, both automakers can hope to prove their good American corporate citizenship and ease the Trump administration’s concerns about jobs moving overseas.

Toyoda denied that Trump’s views influenced his decision.

“We have been reviewing the best production strategy for our business,” he told reporters at a Tokyo hotel, after shaking hands with Mazda President Masamichi Kogai.

Trump welcomed the announcement in a tweet: “Toyota & Mazda to build a new $1.6B plant here in the U.S.A. and create 4K new American jobs. A great investment in American manufacturing!”

The companies also plan to work together on various advanced auto technology, such as electric vehicles, safety features and connected cars, as well as products that they could supply each other, they said.

Toyota plans to acquire 31,928,500 shares of common stock newly issued by Mazda through a third-party allotment, which will amount to a 5.05 percent stake in Mazda, valued at $455 million.

Mazda, which makes the Miata roadster, will acquire the equivalent of a 0.25 percent stake in Toyota. The investment deal is expected to be final by October, the companies said.

Toyoda noted the growing competition from newcomers in the auto industry such as Google, Apple and Amazon, stressing that he was worried about autos turning into commodities. He praised Mazda as a great partner in that effort.

“It has also sparked Toyota’s competitive spirit, increasing our sense of not wanting to be bested by Mazda. This is a partnership in which those who are passionate about cars will work together to make ever-better cars,” he said.

The companies said their collaboration will respect their mutual independence and equality. Toyota, which makes the Prius hybrid, Camry sedan and Lexus luxury models, already provides hybrid technology to Mazda, which makes compact cars for Toyota at its Mexico plant.

The sheer cost of the plant also makes a partnership logical, as it boosts cost-efficiency and economies of scale.

Working together on green and other auto technology also makes sense as the segment becomes increasingly competitive because of concerns about global warming, the environment and safety.

“Given the massive level of competition in the industry, partnerships are no longer a surprise,” said Akshay Anand, an executive analyst at Kelley Blue Book.

Politics are another incentive.

“The new presidential administration has made it clear that investments in the U.S. are a top priority, and this plant may be another nod to that mindset,” Anand said.

Mazda’s president said he hoped that the partnership will help energize the industry.

Toyota is vying for the spot of No. 1 automaker in global vehicle sales against Nissan-Renault and Volkswagen AG of Germany, as the industry gradually consolidates.