A delegation from Paris including Cécilia Sarkozy, the wife of the French president, and Benita Ferrero-Waldner, the EU commissioner for foreign affairs, arrived in Libya at the weekend to negotiate their return home.

France had been seeking the return of the six - in jail for the past eight years - as a final goodwill gesture from Libya after it commuted their death sentences in favour of life in prison.

The accord included measures to improve the medical care of children with HIV/Aids in Libya, the French presidential palace said.

Bulgaria's president, Georgi Parvanov, expressed satisfaction with the long-awaited return home of the medics.

"The dramatic case of the sentencing of innocent Bulgarian citizens is at its end," Mr Parvanov's press office said in a statement. "We are still sympathetic to the other tragedy - the one of the infected Libyan children and their families."

Nicolas Sarkozy and the European commission president, José Manuel Barroso, welcomed "the gesture of humanity by Libya's highest leader", the same statement said, adding that they were also grateful to Qatar for mediating in the case.

Before the nurses were handed over, Libyan officials said on condition of anonymity that Mr Sarkozy was to visit Libya tomorrow provided that the medics were allowed to go home.

Bulgaria made an official request last week for Tripoli to repatriate the medics to serve their sentences in Bulgaria. It also granted citizenship to the Palestinian doctor, Ashraf al-Hazouz, last month. This latest visit to Libya was Ms Sarkozy's second on behalf of the prisoners and, like the first, it drew criticism from the opposition Socialists at home. One opposition MP said the president, who took office on May 16, was profiting from the work of other nations and the EU, which have worked on behalf of the nurses for years.

The medics were sentenced to death in December 2005 after being convicted of infecting 426 children with HIV while working at a hospital in the city of Benghazi. Fifty-six of the children have since died.

In jail since 1999, the medics always maintained their innocence and said they were tortured to make them confess. Western scientists say negligence and poor hospital hygiene were the real culprits and that the six were scapegoats.

Last week Libya's high judiciary council commuted death sentences on the six following the decision of the victims' families to drop demands for their execution after receiving compensation payments.