Russia has agreed to mediate an exit strategy with Muammar Gaddafi after appeals by US President Barack Obama and French President Nicolas Sarkozy for help in ending the stalemate in Libya.

The announcement came as sources said Mr Obama had asked the Russians at the G8 meeting in Deauville, France, to pass on a message that the Libyan leader's safety would be guaranteed if he fled to another country. Russian President Dmitry Medvedev said: "I have offered our mediating services to our partners. Everyone believes that it would be useful."

Washington is hoping assurances Gaddafi will not be pursued if he leaves Libya will finally persuade him to make an exit. He has clung to power despite the two-month Nato bombing campaign against his armed forces, military assets and command centres.

Mr Sarkozy said: "Yes, we need Mr Medvedev's help. This help is welcome."

Ben Rhodes, deputy national security adviser at the White House, said: "The Russians have long-standing relationships in Libya that we don't have."

The announcement was a major diplomatic coup for the Kremlin. It opposed the Western bombing campaign against Gaddafi's forces and abstained from the United Nations Security Council resolution in March that sanctioned the use of force to protect Libyan civilians.

But it has expressed growing unease about Nato's ability to finish the job quickly.