NASA’s InSight lander touched down safely on the Martian surface Monday, after a six-month journey to the Red Planet.

InSight’s dangerous descent through the Martian atmosphere, after a trip of 300 million miles, had nerves stretched to the max. Although its scientists are old pros at this, NASA last attempted a landing on Mars six years ago.

The robot, designed to explore Mars’s mysterious insides, went from 12,300 miles per hour to zero in six minutes as it pierced the atmosphere, popped out a parachute, fired descent engines and landed on three legs.

Flight controllers at NASA’s Jet Propulsion Laboratory in Pasadena, California, leaped out of their seats and erupted in screams, applause and laughter as the news came in. People hugged, shook hands, exchanged high-fives, pumped their fists, wiped away tears and danced in the aisles.

“Flawless,” declared JPL’s chief engineer, Rob Manning. “What a relief.”

“Landing on Mars is one of the hardest single jobs that people have to do in planetary exploration,” InSight lead scientist Bruce Banerdt noted before the landing. “It’s such a difficult thing, it’s such a dangerous thing that there’s always a fairly uncomfortably large chance that something could go wrong.”

NASA has pulled off seven successful landings on Mars in the past four decades. Only one touchdown failed. No other country has managed to set and operate a spacecraft on the dusty red surface.

The stationary 800-pound lander will use its six-foot robotic arm to place a mechanical mole and seismometer on the ground.

The self-hammering mole will burrow 16 feet down to measure the planet’s internal heat, while the ultra-high-tech seismometer listens for possible marsquakes. Nothing like this has been attempted before at our smaller next-door neighbor, nearly 100 million miles away.

No experiments have ever been moved robotically from the spacecraft to the Martian surface. No lander has dug deeper than several inches, and no seismometer has ever worked on Mars.

By examining the deepest, darkest interior of Mars, scientists hope to create 3-D images that could reveal how our solar system’s rocky planets formed 4.5 billion years ago and why they turned out so different. One of the big questions is what made Earth so friendly to life.

Mars once had flowing rivers and lakes; the deltas and lake beds are now dry, and the planet is cold.

The planetary know-how gained from InSight’s two-year operation could even spill over to rocky worlds beyond our solar system, according to Banerdt. The findings on Mars could help explain the type of conditions at these exoplanets “and how they fit into the story that we’re trying to figure out for how planets form,” he said.

Concentrating on planetary building blocks, InSight has no life-detecting capability. That will be left for future rovers. NASA’s Mars 2020 mission, for instance, will collect rocks for eventual return that could hold evidence of ancient life.

Because it’s been so long since NASA’s last Martian landfall — the Curiosity rover in 2012 — Mars mania is gripping not only the space and science communities, but also everyday folks.

Viewing parties were planned coast to coast at museums — including the National Air and Space Museum’s Udvar-Hazy Center — planetariums and libraries.