It was pretty flimsy evidence, but Colonel Gaddafi, Libya's ruler, was desperate to end the Western trade embargo against his country. He never admitted blame in the Pan Am affair, but he handed al-Megrahi and a colleague over for trial in a Western court.

Al-Megrahi's trial took place in 2001. His colleague was freed, but he was jailed for 27 years (in Scotland, because Pan Am 103 came down in Lockerbie). As time passed, however, the case began to unravel.

The Maltese shopkeeper who had identified al-Megrahi, Tony Gauci, turned out to be living in Australia, supported by several million dollars the Americans had paid him for his evidence.

The allegation the timer for the bomb had been supplied to Libya by the Swiss manufacturer Mebo turned out to be false. The owner of Mebo, Edwin Bollier, revealed that he had turned down an offer of $4 million from the FBI in 1991 to testify that he had sold his MST-13 timers to Libya.

One of Bollier's former employees, Ulrich Lumpert, did testify at al-Megrahi's trial that MST-13 timers had been supplied to Libya - but in 2007 he admitted he had lied at the trial.

And this year it was revealed Pan Am's baggage area at London's Heathrow airport was broken into 17 hours before Pan Am 103 took off. (The police knew that 12 years ago, but kept it secret at al-Megrahi's trial.) The theory the fatal bag was put on a feeder flight from Malta became even less likely.

All of which explains why the Scottish Criminal Cases Review Commission announced in 2007 that it would refer al-Megrahi's case to the Court of Criminal Appeal in Edinburgh because he "may have suffered a miscarriage of justice".

The review commission's decision caused a crisis, because a new court hearing would reveal how shoddy the evidence was. Happily for London and Washington, al-Megrahi was now dying of cancer, so a deal was possible.

He would give up his plea for a retrial, no dirty linen about the original trial would be aired in public, and he would be set free.

A miserable story, but hardly a unique one. A man who was probably innocent of the charges against him, a loyal servant of the Libyan state who was framed by the West and hung out to dry by his own Government, has been sent home to die.

* Gwynne Dyer is an independent London-based journalist.

By Gwynne Dyer | Email Gwynne