The two firms are also planning a joint venture to build a shared $1.6bn (£1.22bn) factory in the United States with the capacity to produce 300,000 cars per year.
"In the past, competition [in the auto industry] was about the race to 10 million unit production, and partnerships were about scale expansion", Toyota President Akio Toyoda said at a press conference in Tokyo on Friday.
Toyota said it plans to open the factory with Mazda by 2021, with the location yet to be decided.
The two carmakers have also agreed to join forces to develop electric vehicle technology, and Toyota is to take a 5% stake in Mazda.
"Toyota and Mazda have been working more closely together, so it is no surprise they will have a plant together", Autotrader.com analyst Michelle Krebs said, adding that Mazda had been searching for USA manufacturing capacity. The Republican president also threatened to impose a hefty fee on Toyota if it were to build its Corolla cars for the USA market at a plant in Mexico.
Chris Richter, managing director of investment company CLSA, said: "By buying a 5% stake (in Mazda), Toyota takes Mazda off the table rather than having it sit out there like a free agent which could someday be used against them".
Toyota wouldn't say where the plant would be built.
Skype And PayPal Join Forces For Easy Money Transfer
After that, you'll have to log in using PayPal and once you send the money it'll even show up in your conversation. If you choose to use a credit card instead, the fee is 3.4 percent of the transaction amount plus $0.30.
Toyota, which is strong in hybrid vehicles but has been behind in entering the electric vehicle market, apparently judged it necessary to strengthen the development of electric cars in cooperation with Mazda. The company solidified a partnership with Suzuki in February and already sources compact cars from Mazda's lone North American assembly plant in Mexico.
He campaigned on promises to increase manufacturing and expand employment for American vehicle workers.
Toyota and Mazda are close to finalising a deal that would see each invest in the other and together build a new joint-owned factory in the USA.
The move carries significant political implications following Trump's verbal assault on Toyota and other companies that sell foreign-made cars in the U.S. It was not immediately clear whether Trump's threats factored into the decision.
Toyota, Japan's biggest carmaker, has been forging alliances with smaller Japanese rivals for several years. "The plant will require a total investment of approximately 1.6 billion US dollars, and will create up to 4,000 jobs", the press release said.
However it's not only electric cars that will benefit from the partnership.
In 2015, Toyota and Mazda reached an agreement to discuss a business alliance.
As we reported earlier today, Mazda and Toyota have indeed taken a step towards increased collaboration, particularly in the U.S.