Rosetta used Mars's gravitational field to change course and head towards two similar fly-bys of Earth this year and in 2009, which will accelerate it towards its distant target comet.
"Rosetta is on its way," said Manfred Warhaut, ESA head of mission operations.
It was a manoeuver the craft was not designed to make, taking it into Mars's shadow where solar panels could not generate electricity to keep its systems alive.
The original Rosetta mission would have taken it on a course where it did not fly through shadow; but a launch delay forced a change to a different target comet.
ESA offficials solved the shadow problem by shutting off many of the spacecraft's instruments and using batteries untested since launch almost three years go.
Rosetta passed the test, flying from shadow into a Martian sunrise at 0240 GMT on Sunday and regaining solar power and a radio signal from the craft's instruments.
The successful fly-by "is fundamental to the mission," said Andrea Accomazzo, the spacecraft operations manager.
"It's a very big success, so we are very happy - and we can go to sleep now."
Rosetta blasted off on March 2, 2004 from Kourou, French Guiana, atop an Ariane-5 booster rocket.
Its destination - in 2014 - is comet 67P/Churyumov-Gerasimenko, a five kilometre [three mile] long irregular chunk of ice, frozen gases and dust named for its discoverers, Soviet astronomers Klim Churyumov and Svetlana Gerasimenko.
Rosetta will go into orbit around it and release a small lander that will touch down and attempt to drill into the surface and radio back an analysis of its makeup.
Because the comet's gravity is so weak, the lander will use a harpoon and spikes to catch hold. Researchers hope it will be able to photograph the dramatic appearance of the comet's tail, a stream of gases and dust that arises when the icy body warms as it orbits nearer the sun.
Comets are among the most primitive objects in the solar system and their composition is considered to hold clues about its early development 4.6 billion years ago.
In 2004, Nasa's Stardust mission flew by a comet, collected thousands of particles that came from it and returned them to Earth for analysis.