The agreement expands upon a technology partnership the companies signed in 2015. Under the new deal, each firm will take a share in the other worth ¥50 billion (£345 million). This gives Toyota a 5.05% stake in Mazda and Mazda a 0.25% share in Toyota.
The alliance will involve the two firms working together to “explore joint technologies” for the development of EVs, along with infotainment, connected car systems and advanced safety technology.
The firms could also supply each other with more badge-engineered models. Toyota currently sells a version of the Mazda 2 rebranded as the Toyota Yaris iA in North America, and under the new deal, Toyota will supply a box truck to Mazda for the Japanese market.
The two firms are also planning a joint venture to build a shared $1.6bn (£1.22bn) factory in the US with the capacity to produce 300,000 cars per year. A site for the plant, which will employ around 4000 people and is intended to be operational by 2021, has yet to be decided.
Toyota president Akio Toyoda said: “The greatest fruit of our partnership with Mazda is that we have found a new partner who truly loves cars.
"This is a partnership in which those who are passionate about cars will work together to make even better cars. It is also the realisation of our desire to never let cars become commodities.”