TOKYO (Reuters) - Toyota Motor Corp said on Friday it planned to take a 5 percent share of smaller Japanese rival Mazda Motor Corp, as part of an alliance that will see the two build a $1.6 billion U.S. assembly plant and work together on electric vehicles.

The plant was a surprise for investors at a time of cooling U.S. sales, but marked good news for U.S. President Donald Trump who came to office on the back of promises to bring back manufacturing and jobs for U.S. workers. He commented on Twitter that it was a “great investment in American manufacturing”.

The plant, whose location is not yet public, will be able to produce 300,000 vehicles a year, with production divided between the two automakers, and employ about 4,000 people. It will start operating in 2021.

Analysts said the plan was more than a political ploy. The alliance is also an attempt to catch up with rivals in the race for electric car technology, as tighter global emissions rules loom, along with the entry of new players into the market.

“There will be new rivals appearing - Apple, Google - these are IT companies, we also need to compete with them, too,” Toyota President Akio Toyoda, grandson of the company’s founder, told a news conference in Tokyo.

He was appointed last year to lead Toyota’s newly formed electric car division, flagging the group’s commitment to a technology it has been slow to embrace.

“What’s different from the past is that there are no nautical charts for us to follow. It’s without precedent,” he said of the push into alternatives to the internal combustion engine.

Toyota Motor President Akio Toyoda and Mazda Motor President Masamichi Kogai bow at a joint news conference in Tokyo, Japan August 4, 2017. REUTERS/Kim Kyung-Hoon

Other traditional automakers such as Daimler and BMW are also weighing how best to work on new, disruptive technology, from electric vehicles to autonomous driving, that require hefty investment and have turned firms like Google and Tesla into rivals.

Toyota has set a goal for all of its vehicles to be zero emission by 2050. But until recently, it has said it favoured EVs for short-distance commuting, given their limited driving range and lengthy charging time.

It has been investing heavily in hydrogen fuel-cell vehicles (FCVs), while rivals such as Nissan Motor Co, Volkswagen AG and Tesla have touted pure electric cars as the most viable zero-emission vehicles.

As part of the agreement, as well as electric car technology, Toyota and Mazda will work together to develop in-car information technologies and automated driving functions.

BULKING UP

Toyota, Japan’s biggest auto company, has been forging alliances with smaller rivals for several years, effectively engineering a loose network at the heart of the Japanese auto sector. It already owns a 16.5 percent stake in sixth-ranked Subaru Corp with which it also has a development partnership.

Toyota is also courting compact car maker Suzuki Motor Corp to cooperate on R&D and parts supply, as Toyota seeks to tap its smaller rival’s expertise in emerging Asian markets.

As part of Friday’s plan, Toyota, the world’s second-largest automaker by vehicle sales last year, will take a 5 percent share of Mazda, and Mazda will take a 0.25 percent share of Toyota.

Mazda said it could even expand the alliance, as long as it could stay in control of its own management. “We will study the possibility of expanding the capital alliance, but the basic premise is that autonomy is assured,” said Mazda Executive Vice President Akira Marumoto.

A stake in Mazda may also prevent future incursions by tech companies, one analyst said.

“For a technology company which lacks the expertise in making cars, Mazda could look like a very interesting acquisition. They’re very good, they’re not too expensive. Maybe Toyota realises this,” CLSA managing director Chris Richter said.

“By buying a 5 percent stake, Toyota takes Mazda off the table rather than having it sit out there like a free agent which could someday be used against them.”

Mazda, for its part, stands to gain from a deal that gives the small automaker a production foothold in the United States. At the moment, it ships all vehicles sold in the country, its biggest market, from its plants in Japan and Mexico.

With an R&D budget of around 140 billion yen ($1.27 billion) this year, a fraction of Toyota’s 1 trillion yen, Mazda lacks the funds to develop electric cars on its own, a predicament shared by Subaru and Suzuki.

“Mazda needs electrification technology. In the past, they’ve pooh-poohed EVs, they’ve felt they can make internal combustion engines more efficient, but the bottom line is that globally you need to have this technology,” said Janet Lewis, head of Asia transportation research at Macquarie Securities.

The automakers plan to produce Toyota Corollas and a new Mazda SUV crossover at the new plant, and the companies said they could eventually build other cars including electric vehicles.

Toyota initially had been planning to produce Corollas at its new $1 billion plant being built in Mexico, prompting Trump to threaten punitive tariffs.

The company has since said it will instead produce its Tacoma truck model in Mexico.