Russia will also remove its check-points and troops from the Black Sea port of Poti under the condition that Georgia signs a pledge not to use force against Abkhazia, the agreement said.
Moscow also agreed to deploy 200 EU observers in Georgia by Oct 1 to monitor the withdraw, adding that an international conference on the Caucasus situation will be held Oct 15 in Geneva.
Sarkozy arrived in Moscow on Monday for talks with Medvedev on the Caucasus situation.
Sarkozy, who is heading an EU delegation, condemned Russia's recognition of the self-proclaimed South Ossetia and another Georgian breakaway region of Akbhazia following the conflict.
"We did not agree on everything. The EU condemns the unilateral recognition by Russia of South Ossetia and Akbhazia," he said, "We are not here negotiating the future, but to make sure the ceasefire was and is fully implemented."
In response, Medvedev said the recognition was "final" and refused to change Russia's stance on that.
Sarkozy and the EU delegation, headed by European Commission President Manuel Barroso and EU foreign policy and security chief Javier Solana, are expected to head for the Georgian capital Tbilisi following talks in Moscow.