CAPE CANAVERAL, Fla. — The United States opened a new chapter in its grand adventure in space Saturday, when a SpaceX rocket blasted off from the Kennedy Space Center, carrying two astronauts to orbit from United States soil for the first time in nearly a decade.

It was a historic moment for SpaceX, which became the first private corporation to launch people into orbit, and for NASA, which has struggled to regain its footing after retiring the Space Shuttle in 2011, leaving the U.S. no option but to rely on Russia to ferry its astronauts to space for as much as $90 million a seat.

Both President Trump and Vice President Pence, the chair of the National Space Council, were in attendance to mark a new era of space flight.

The flight was the the fulfillment of a risky bet by NASA under the Obama administration to entrust the private sector to fly astronauts.

For SpaceX, it was the climax of an improbable odyssey that began in 2002 when Elon Musk founded a space company with the goal of traveling to Mars.

SpaceX’s Falcon 9 rocket lifted off at 3:22 p.m. from pad 39A, the historic site from which the crew of Apollo 11 left for the moon, after a seamless countdown where the primary concern was inclement weather that on Wednesday had forced a postponement of the first launch attempt.

The Crew Dragon capsule, which separated from the booster on time 12 minutes into the flight, is expected to dock with the International Space Station shortly after 10 a.m. Sunday.

On board the spacecraft are two of NASA’s most experienced space travelers, Bob Behnken and Doug Hurley, both former military pilots who previously had each flown two missions on the Space Shuttle. But their ride to space this time was on a vastly different spacecraft, a fully autonomous, next-generation capsule outfitted with Tesla-like touchscreens and temperature controls that allow astronauts to keep the cabin at between 65 and 80 degrees Fahrenheit.

The launch came 3,250 days after the last shuttle mission blasted off.

Hurley, a retired Marine Corps Colonel, was a crew member on that last shuttle mission, which took off in July 2011, also from pad 39A. It was the end of the shuttle’s 30-year life span, and a devastating blow to an agency that suddenly had no way to fly its astronauts anywhere.

Despite repeated warnings by NASA to stay home because of the coronavirus, fans lined the beaches to watch a historic moment, but the space agency drastically limited attendance at the Kennedy Space Center.

Sunday’s docking will be handled autonomously by the spacecraft, though Hurley and Behnken have the ability to take over the controls manually if needed.

The mission, known as Demo-2, was a test flight designed to ensure the rocket and spacecraft can fly humans safely. Once complete, NASA and SpaceX would review the data and certify the spacecraft for additional missions that would regularly fly as many as four astronauts to the space station and back.

In 2014, NASA awarded contracts to Boeing and SpaceX, worth $6.8 billion combined, to design and build spacecraft capable of flying astronauts to the station. Previously, it had hired the private sector to fly cargo and supplies there. But outsourcing human space flight to companies was considered a risky and even reckless move in some quarters, even among NASA’s leadership. Along the way there had been a number of stumbles that delayed the first flights from 2017.

Boeing, the aerospace behemoth that had been by NASA’s side since the dawn of the Space Age, was considered the favorite to fly first. But it stumbled when the test flight of its Starliner spacecraft encountered trouble almost immediately upon reaching orbit. Boeing and NASA officials scrambled to fix software problems that prevented the spacecraft from reaching the space station and instead ending the mission early.

SpaceX also ran into a series of problems. In 2015, one of its Falcon 9 rockets exploded on a cargo resupply flight to the station. The next one, another rocket blew up, this time on the launch pad before an engine test. Then, last year, its Crew Dragon spacecraft blew up during a test of its abort engines.

But it has since investigated and remedied those failures to NASA’s satisfaction, and in the days leading up to the launch, the space agency praised the company many in the agency once looked upon skeptically.