The US space agency's (Nasa) Mars rover Opportunity has finally broken free of the sand trap that has prevented it from rolling over the Red Planet.
The robot vehicle started to experience wheel slippage while trying to traverse a ripple-shaped dune on 26 April.
Engineers used a model rover back on Earth to work out a driving strategy to release Opportunity from the deep dirt.
And at the weekend the rover confirmed it was rolling free again with images showing the wheels had good traction.
"After a nerve-wracking month of hard work, the rover team is both elated and relieved to finally see our wheels sitting on top of the sand instead of half buried in it," said Jeffrey Biesiadecki, a Nasa rover mobility engineer.
Nasa said it would study Opportunity's surroundings carefully before commanding the vehicle to take a long drive.
Engineers want to be sure there are not any other sand traps close by that could catch the vehicle for a second time.
"The first thing we're going to do is simply take a hard look at the stuff we were stuck in," said Dr Steve Squyres, the principal investigator for the Mars rovers' science instruments.
"After that, we will begin a cautious set of moves to get us on our way southward again. South is where we think the best science is, so that's still where we want to go."
The mission team simulated the escape on an engineering model
Opportunity and its twin rover, Spirit, have been studying the geology on opposite sides of the planet for more than a year since successfully completing their three-month primary missions.
The robots have worked superbly under harsh Martian conditions far longer than expected.
Shortly after landing in January 2004, Opportunity found layered bedrock bearing geological evidence of a shallow ancient sea.
More than one year later, Spirit found extensive layered bedrock after driving for about three km and climbing into the "Columbia Hills."