The Mars Atmosphere and Volatile EvolutioN (MAVEN) spacecraft has been orbiting Mars for just over two years, studying the red planet's upper atmosphere, ionosphere and interactions with the sun and solar wind.
The spacecraft carried out a rocket motor burn that boosted its velocity by 0.4 metres per second.
Although a small correction, it was enough that MAVEN would miss the crater-filled moon by about 2.5 minutes.
This is the first collision avoidance manoeuvre that the MAVEN spacecraft has performed at Mars to steer clear of Phobos.
The orbits of both MAVEN and Phobos are known well enough that this timing difference ensures that they will not collide.
MAVEN, with an elliptical orbit around Mars, has an orbit that crosses those of other spacecraft and the moon Phobos many times over the course of a year.
When the orbits cross, the objects have the possibility of colliding if they arrive at that intersection at the same time.
These scenarios are known well in advance and are carefully monitored by NASA's Jet Propulsion Laboratory (JPL) in California, which sounded the alert regarding the possibility of a collision.
With one week's advance notice, it looked like MAVEN and Phobos had a good chance of hitting each other on Monday, March 6, arriving at their orbit crossing point within about 7 seconds of each other.
Given Phobos' size, they had a high probability of colliding if no action were taken.
"Kudos to the JPL navigation and tracking teams for watching out for possible collisions every day of the year, and to the MAVEN spacecraft team for carrying out the manoeuvre flawlessly," said MAVEN Principal Investigator Bruce Jakosky of the University of Colorado in Boulder.