The supreme court overturned death sentences against five Bulgarian nurses and a Palestinian doctor and ordered them retried on charges of infecting children with the HIV virus, in an attempt by Libya to resolve a case that has poisoned its ties with the West. Libyan leader Moammar Gadhafi is believed to have been looking for face-saving way out of the standoff over the case, which brought condemnations from Europe and the United States and stalled his campaign to bring his country out of its international pariah status. The verdict, welcomed by Bulgaria, came after European and Libyan negotiators reached a deal by which the West will provide aid to families of the 426 children infected in the 1990s with the virus that causes AIDS. Around 50 of the children have reportedly died. The ruling lifts the threat of execution by firing squad hanging over the five Bulgarian women and the Palestinian doctor since last year - but it means more time in Libyan prisons, where they have been since 1999. Libya accused them of deliberately infecting the children at a Benghazi hospital as part of an experiment. But Europe, the United States and human rights groups said Libya trumped up the charges to cover up poor hygiene conditions at its hospitals that they say caused the infections. The six health workers said they were tortured to extract confessions. Ruling on their appeal Sunday, the judge at Libya's supreme court suggested he believed the defense allegations of torture. "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. Bulgaria welcomed the verdict as a "positive sign" and said it hoped the retrial would be held quickly. "The Libyan court's decision is an encouraging step toward a final recognition of the innocence of our compatriots," Bulgarian parliament speaker Georgi Pirinski said. The defendants' Libyan lawyer said the ruling "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." The defendants did not attend Sunday's session. A date for the retrial was not immediately set. 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. Another lawyer for the families vowed the six would still be found guilty. "The verdict will delay achieving justice for years because the retrial takes a long time. We will be ready and we have enough evidence to incriminate them," Ramadan al-Faytouri 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. The prosecution of the medics has plagued Gadhafi's campaign to rebuild ties with the West. In 2003, Libya accepted responsibility for the 1988 bombing of a Pan Am jetliner over Lockerbie, Scotland, and agreed to compensate families of the 270 victims. It also voluntarily scrapped its nuclear program, handing its material over to the United States and United Nations. In response, the US government lifted 23-year-old travel restrictions imposed on Libya, invited American companies to return to the oil-rich nation and encouraged Tripoli to open a diplomatic office in Washington. But Washington has made it clear that the nurses' case is a key sticking point that must be resolved before the United States will reopen an embassy in Tripoli, a top goal for Gadhafi. "There should be no confusion in the Libyan government's mind that those nurses ought to be not only spared ... but out of prison," US President George W. Bush said in October. The European Union has also said relations with Libya hinge on the fate of the Bulgarians. In months of negotiations over the nurses, Bulgaria rejected Libyan proposals it pay compensation to families of the infected children, saying that would imply the medical workers' guilt and amount to blackmail. But 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. The amount of aid has yet to be announced. Bulgarian President Georgi Parvanov on Saturday predicted from the supreme court "a positive result which is expected for such a long time." But, he added, "the release will come at a very high price."