The comet, known as Siding Spring (C/2013 A1), made its closest encounter with Mars on Sunday at 2:27 pm (1827 GMT), racing past the Red Planet at a breakneck 126,000 miles (203,000 kilometers) per hour.
At its closest, Siding Spring was 87,000 miles (139,500 kilometers) from Mars -- about a third the distance between Earth and our moon.
Before the comet passed, it could be seen in space racing toward the brightly illuminated Red Planet, trailed by a cloud of debris.
Scientists said the comet's passing offered a unique chance to study its impact on Mars's atmosphere.
"What could be more exciting than to have a whopper of an external influence like a comet, just so we can see how atmospheres do respond?" asked Nick Schneider, the remote sensing team leader from NASA's MAVEN mission to Mars.
"It's a great learning opportunity."
NASA's fleet of Mars-orbiting satellites and robots on the planet's surface were primed for the flyby of the comet, hoping to capture the rare event and collect a trove of data for Earthlings to study.
MAVEN, NASA's latest Mars orbiter, reported back to Earth in "good health" after spending about three hours ducking a possible collision with the comet's high-velocity dust particles, the US space agency said.
"We're glad the spacecraft came through, we're excited to complete our observations of how the comet affects Mars, and we're eager to get to our primary science phase," said MAVEN principal investigator Bruce Jakosky.
"Mars Odyssey hard at work now to image #MarsComet Siding Spring, after closest approach & before dust tail hits," NASA said on Twitter, referring to one of its robotic spacecraft.
The ball of ice, dust and pebbles is believed to have originated billions of years ago in the Oort Cloud, a distant region of space at the outskirts of the solar system.
The comet is around one mile wide and is only about as solid as a pile of talcum powder.
As it hurtled through space it created a meteor shower and shed debris -- mostly dust and pebbles -- which scientists had feared could damage valuable spacecraft.
"All it takes is a little tiny grain of sand traveling at that speed and you've got damage to solar arrays, or your propulsion line or critical wires," said Schneider. Before the comet entered the red Planet's orbit, NASA moved its Mars Reconnaissance Orbiter, Mars Odyssey and MAVEN to avoid damage by the comet's high-speed debris.
"#MarsComet flyby not over yet. Mars passes thru dust tail... while orbiters #duckandcover on far side," the agency tweeted.
The comet has traveled more than one million years to ake its first pass by Mars, and will not return for another million years, after it completes its next long loop around the sun.
The comet was discovered by Robert McNaught at Australia's Siding Spring Observatory in January 2013.
Its flyby of Mars is not likely to be visible to sky watchers on Earth.
Election Results for Lok Sabha Election 2019 will be out on May 23. Get the latest election news and live updates on ndtv.com/elections. Catch all the action on NDTV Live. Like us on Facebook or follow us on Twitter and Instagram for news updates from each of the 543 parliamentary seats for the election 2019