Electric carmaker Tesla Motors announced Thursday it picked up a $50 million investment from Toyota, the world's biggest auto company.

When Tesla begins selling its stock to the public, Toyota will fork over the $50 million for a stake of about 2.5 percent.

The funding will help Tesla buy one of Toyota's California manufacturing plants: a former Nummi factory with a capacity to build 400,000 vehicles a year that was closed down in April because of the recession. The factory – formerly a joint venture between Toyota and General Motors – will be used to build Tesla's Model S electric sedan.

"The new Tesla factory will give us plenty of room to grow," said Elon Musk, chief executive of Tesla, at a California press conference held to announce the deal. PayPal co-founder Musk, who is also the six-year-old start-up's founder, was Inc.'s Entrepreneur of the Year in 2007.

Akio Toyoda, president of Toyota and the grandson of its founder, said in a statement: "By working together with a venture business such as Tesla, Toyota would like to learn from the challenging spirit, quick decision-making and flexibility that Tesla has. Decades ago, Toyota was also born as a venture business."

Tesla so far has built only 1,000 of its $100,000 Roadster electric sports cars, which largely were made in England. The Model S is designed to be a cheaper, more practical family car, with a price tag of about $50,000. Tesla has received $465 million in federal loans to help keep the price down.

Xavier Mosquet, a senior partner with Boston Consulting Group, told the Los Angeles Times that the deal brightens Tesla's future. "When an established manufacturer decides to partner with one of these newcomers, it considerably increases their probability of success," he said. "It would give them manufacturing know-how and access to a distribution network."

The deal also could help Toyota fix its tarnished image after massive recalls of many of its car models due to sticking accelerator pedals and protests over the decision to close the plant Tesla is buying. According to Reuters, the "whirlwind corporate romance" between the two companies included a dinner at Musk's house and a test drive around Los Angeles in an electric Roadster.

Other Tesla investors include Google co-founders Larry Page and Sergey Brin and the government of Abu Dhabi. Daimler, the world's second biggest luxury car company, invested a year ago. (According to Tesla, Musk told Daimler about the Toyota deal Thursday.)