©AFP

FEW would have predicted precisely this outcome.

On Tuesday July 24th five Bulgarian nurses and a Palestinian doctor, who had been imprisoned for more than eight years in Libya, were finally freed. The six workers had been convicted of deliberately infecting some 400 children in eastern Libya with HIV, despite their claims of innocence and despite evidence that the children probably contracted the virus as a result of poor hospital hygiene. The medics had faced the death penalty, but last week their sentence was commuted to life imprisonment after a mysterious payment of $460m was agreed to be made - through an international fund - to the victims' families.

Their release is the result of long-running diplomatic efforts by the European Union (EU), and more recently by France's new limelight-loving president, Nicolas Sarkozy. The French president had promised during his election campaign to make the jailed medics a priority of his foreign policy. Most unusually this month he twice sent his wife, Cécilia Sarkozy, and his chief of staff, Claude Guéant, to Libya's capital to lobby for their freedom. In Tripoli his entourage met Colonel Muammar Qaddafi, visited the imprisoned medics and talked to the families of the victims. The medics were finally flown home in Mr Sarkozy's presidential jet.

The involvement of the president's once-estranged and rather reluctant first Lady has provoked some concern and irritation. EU officials privately grumble that Mr Sarkozy is trying to steal their glory. Benita Ferrero-Waldner, the EU's external-relations commissioner who brokered a substantive deal on medical aid and political ties with Libya, was particularly surprised by the late intervention of Mr Sarkozy's wife.

Within France there are grumbles too, and uncertainty about the role of the first Lady. The prime minister, François Fillon, said that she was acting merely as a humanitarian symbol for France. Bernard Kouchner, the foreign minister, appeared uninvolved. The opposition Socialists, wrongfooted again by Mr Sarkozy, complain that members of his unelected entourage are bypassing official channels. The French president himself is due to fly to Tripoli on Wednesday, with Mr Kouchner.

More important in the long term should be the partnership deal hammered out by Mrs Ferrero-Waldner and Libya. Mr Sarkozy and others deny that the EU or France paid any ransom money for the medics' release. But official assistance may now flow towards Libya. The European Commission president, José Manuel Barroso, suggests that a normalisation of relations with the EU is now possible. Libya's foreign minister, Abdel Rahman Shalqam, has also said the deal will allow for "full co-operation and partnership" with the EU. Libya is expected to receive EU aid to pay for the rehabilitation of some hospitals, along with assistance to block illegal immigration to Europe, to protect archeology in Libya, to improve education and more.

The latest co-operation is part of a process of bringing Libya into the mainstream of international politics, after decades as an enemy of the West. In recent speeches, Mr Qaddafi has said Libya cannot resist the tide of globalisation, and that there can be no going back to the "era of hostility and confrontation" when Western powers ostracised him for sponsoring terrorism. There will come a day, he promises, when his people no longer have need of their leader. Yet he has also complained that America and Britain have cheated Libya, by failing to reward it adequately for its decisions to scrap its nuclear-weapons programmes and to accept liability for the airliner bombing over Lockerbie in 1988. His contradictory speeches are likely to continue for some time yet. But Mr Qaddafi, and Libya, seem on their way to becoming rather more friendly to the West than ever before.