The Hawthorne, California-based aeronautics company was founded in 2002 to "revolutionize space technology" and enable multiplanitary human existence and the ability to live on Mars in particular.
To try and compete in the rocket industry was risky.
"I had so many people try to talk me out of starting a rocket company, it was crazy," Musk told Scott Pelley on CBS's "60 Minutes" in 2014. "One good friend of mine collected a whole series of videos of rockets blowing up and made me watch those. He just didn't want me to lose all my money."
Musk had made a reported $180 million when online payments company PayPal sold to eBay for $1.5 billion in 2002.
Early on, Musk had a hard time bringing on top talent.
"The reason I ended up being the chief engineer or chief designer was not because I wanted to, it was because I couldn't hire anyone. Nobody good would join. So I ended up being that by default," Musk said at IAC in 2017.
And in 2008, SpaceX almost died.
At the time, the company was trying to successfully launch the its first rocket, the Falcon 1.
"I messed up the first three launches. The first three launches failed," Musk remembered, speaking at IAC in Australia.
Plus, his electric automobile company, Tesla, founded in 2003, was struggling. The U.S. economy was tanking. "And I'm getting divorced, by the way, add to that. That was definitely the worst year of my life," Musk told Pelley.
"A fourth [rocket launch] failure would have been absolutely game over," said Musk. "Yeah. It's bad enough to have three strikes, having four strikes is really kaput."
But finally, a ray of hope.
"[F]ortunately, the fourth launch, which was ... the last money that we had for Falcon 1 — that fourth launch worked. Or it would have been — that would have been it for SpaceX. But fate liked us that day. So, the fourth launch worked," Musk said at IAC.
After SpaceX successfully launched its first rocket that September, the company got a government contract, which buoyed business.
"NASA called and told us that we'd won a $1.5 billion contract. And I couldn't even hold the phone, I just blurted out, 'I love you guys,'" Musk told Pelley.
Since the dark days of 2008, SpaceX has evolved from a near failure to a success story.
According to Musk, it's all driven by his desire to get to Mars, so that he can help build a better future.
"It's important to have a future that is inspiring and appealing," said Musk in a 2017 TED talk.
"I just think there have to be reasons that you get up in the morning and you want to live. Like, why do you want to live? What's the point? What inspires you? What do you love about the future?
"And if we're not out there, if the future does not include being out there among the stars and being a multiplanet species, I find that it's incredibly depressing if that's not the future that we're going to have."