Libya's supreme court on Sunday overturned the death sentences and ordered a retrial for five Bulgarian nurses and a Palestinian doctor charged with infecting children with the HIV virus which causes AIDS.

The order appeared to be an attempt to end the standoff between Libya and the West over the prosecution of the six. Bulgaria's president said Saturday he was hopeful for a breakthrough in the case after a deal was reached between Libyan and European negotiators.

The six medical workers have been in jail since 1999. Human rights groups allege that Libya concocted the charges to cover up unhygienic practices in its hospitals that led to the infections.

The case had poisoned Libyan leader Moammar Gadhafi's attempts to rebuild ties with the West.

Europe and the United States accused Libya of making up the charges that the nurses and doctor deliberately infected 400 children with the HIV virus at a hospital in the Libyan city of Benghazi. At least 50 of the 426 children infected with the virus are reported to have developed AIDS and died.

The supreme court in Tripoli backed their appeal, suggesting that it believed the defense's arguments that the six had been tortured to extract confessions.

"The court has accepted the appeal in form and in content, and a retrial should be carried out by the Benghazi Criminal Court," the judge pronounced. He said prosecutors agreed with defense lawyers that there were "irregularities" in the arrest and the interrogation of the medical workers.

"The verdict reflects the evidence and facts that we have presented, that all the previous measures were null and void and that the confessions were made illegally. We will be ready for the new trial," defense lawyer Othman al-Bezenti said.

The defendants did not attend Sunday's session.

Awad al-Mesmari, a lawyer for the families of the infected children, said he was "saddened" by the verdict.

"What did the children do so that they suffer now? We have buried 50 of them, may God bless them," he said.

The trial has stoked anger within Libya, with the families of the infected children demonstrating at every court session and reacting with outrage at the repeated delays in carrying out the original verdict.

Relatives, some of them carrying their children, scuffled with riot police surrounding the court during Sunday's session and tried to force their way inside.

"Merry Christmas to you, nurses, but what did we do to you that you infect us?" read one banner they carried.

A date for the retrial was not immediately set. Though it raises hopes for their eventual release, the new trial means more time in detention for the five female nurses and the Palestinian doctor.

The six were first arrested in 1999 and convicted in May 2004. But the nurses said they had been tortured to extract confessions. They were sentenced to death by firing squad.

On Thursday, a deal was announced under which Bulgaria, the United States, Britain and the European Union agreed to set up a non-governmental organization to collect and distribute financial and material help to the families of the infected children.

In previous talks, Bulgaria rejected paying compensation to the families, saying that would imply the medical workers' guilt and amount to blackmail. But in Thursday's deal, they did agree to contribute.

Bulgarian state radio on Saturday quoted Idris Laga, a Libyan representative of the parents of the infected children, as saying that on Dec. 28 the Libyan side will announce the amount of compensation that the families are requesting.

Bulgarian President Georgi Parvanov said Saturday he expected a breakthrough.

"There does appear to be some light at the end of the tunnel," he said. But he added: "The release will come at a very high price."