Like any startup company, Tesla Motors has had crises where the electric-car maker came very close to financial collapse.

One was in 2008, when its Roadster model was late in delivery and its two-speed transmission proved unable to handle the car's power.

But a second crisis developed in late 2012 and early 2013, when sales of its Model S electric luxury sedan were much slower than expected.

DON'T MISS: First 2012 Tesla Model S Delivered To Earliest Depositor Steve Jurvetson: Video (Jun 2012)

As related by Bloomberg in an excerpt from an upcoming book, Elon Musk: Tesla, SpaceX, and the Quest for a Fantastic Future, the earliest buyers who had put down deposits on the Model S were deferring their orders in large numbers.

The car that had finally launched in June 2012 performed as promised, with a range of 208 or 265 miles and the hot-rod P85 model.

But it was also missing certain features--adaptive cruise control and parking sensors among them--that were standard in cars starting at $65,000 or more.

First production 2012 Tesla Model S [detail from photo by evancharlesmoore on instagram]

First production 2012 Tesla Model S [detail from photo by evancharlesmoore on instagram]

And teething troubles along with some substandard interior parts (the cheapness of the sun visors was a particular sore point) meant that many buyers decided it might be better to wait a few months for the bugs to be worked out.

The slowdown in deliveries threatened to sink the company just as it was ramping up production and paying out huge sums for parts and equipment.

When CEO Elon Musk found out that senior executives had hidden the scope of the problem, he marshaled every employee and told them their new job was to ensure that the company survived by closing as many deliveries as they could, as soon as possible.

ALSO SEE: Tesla Didn't Make A Profit On Its Cars In Q1: Let's Be Clear (May 2013)

At the same time, Musk embarked on a deal with his friend and Google cofounder Larry Page for Google to buy Tesla, subject to several conditions.

Those included not breaking up the company, letting Musk run it for eight years or until its third-generation Model 3 car was in production, and various other financial terms.

Google would have paid $6 billion for Tesla Motors, its value at the time plus a healthy premium, and invested a further $5 billion for expansion.

2012 Tesla Model S beta vehicle, Fremont, CA, October 2011

2012 Tesla Model S beta vehicle, Fremont, CA, October 2011

The two men shook hands on the deal during the first quarter of 2013. The company had just two weeks' cash in the bank.

But the all-out sales push by every Tesla employee started to pay off, and the pace of deliveries soared during March 2013.

The company ended the quarter with a completely unexpected profit (using its own non-standard accounting methodology), and deliveries accelerated still more once that profit was announced.

MORE: Tesla Repays $465-Million DoE Loan, Chrysler Bites Back At Claim (May 2013)

Shares of Tesla Motors doubled in the two weeks following that announcement, and cash began to accumulate in its accounts once again.

Musk announced that Tesla would repay its $465 million low-interest loan from the U.S. Department of Energy several years early, using the proceeds from a new stock offering.

And he was able to walk away from the deal with Google.

As Bloomberg notes, "Tesla no longer needed a savior."

_________________________________________________

Follow GreenCarReports on Facebook, Twitter, and Google+.