SpaceX returned two NASA astronauts to Earth on Sunday after flying them to the International Space Station.

The mission, called Demo-2, flew the first crewed US spacecraft since the end of NASA's space shuttle program in 2011.

SpaceX's Crew Dragon spaceship is a product of NASA's Commercial Crew program, a partnership between the space agency and private companies.

Boeing is also building a spaceship as part of the program, but SpaceX's progressed faster.

Visit Business Insider's homepage for more stories.

SpaceX and NASA celebrated a major milestone on Sunday: the completion of the world's first crewed commercial spaceflight.

The company's Crew Dragon spaceship carried two NASA astronauts into orbit and docked to the space station two months ago, then returned on Sunday in a fiery plunge through Earth's atmosphere.

The mission, called Demo-2, was the last major test before NASA certifies the Crew Dragon to carry more people into space.

"This day heralds a new age of space exploration," Elon Musk, SpaceX's CEO, said during a NASA TV broadcast after the splashdown, adding, "I'm not very religious, but I prayed for this one."

Since NASA ended its space-shuttle program in 2011, the agency has relied exclusively on Russia to ferry its astronauts to and from orbit in Soyuz spacecraft. But those seats have gotten increasingly expensive, and the world's space agencies have had no alternative for launching and returning astronauts, even when technical glitches have arisen.

That's what spurred NASA to launch its Commercial Crew program, which was designed to facilitate the development of new American-made spacecraft.

The program put private firms in competition for billions of dollars' worth of government contracts. SpaceX and Boeing came out on top, and SpaceX's spaceship passed its tests and became ready for astronauts first.

Here's how NASA came to rely on the two companies to resurrect American spaceflight.