Last week saw more than its share of stories about miscarriages of justice. But spare a thought this Christmas for the victim of the biggest miscarriage of justice in Scottish legal history, Abdelbaset Ali Mohmed al-Megrahi, the man convicted of blowing up Pan Am flight 103 en route from London to New York, 20 years ago today.

For many years, it looked as if there would be no trial over Lockerbie. British and US governments believed Colonel Gaddafi would never hand over the two Libyan intelligence officers accused of the bombings, which some regarded as fortunate as they believed the evidence against Libya would not stand up in a court of law.

But thanks largely to the persistence of Nelson Mandela, 12 years after the bombing a trial did take place. In exchange for the lifting of sanctions Gaddafi handed over the two accused and the Scottish court swallowed almost the whole improbable story. On 31 January 2001, Megrahi was convicted of the mass murder of 259 passengers and crew, as well as 11 people on the ground in the village of Lockerbie. He is now serving a life sentence in a Scottish jail. His co-accused, Al Amin Khalifa Fhimah, was acquitted.

Download the new Independent Premium app Sharing the full story, not just the headlines

Megrahi's conviction was a shocker. No material evidence was presented linking him to the bombing, let alone any evidence that he put the bomb on the plane or that he handled any explosives. Even the prosecution subsequently questioned the credibility of its star witness.

Nevertheless, keen to move on, Libya accepted responsibility for the bombing although it never accepted guilt. Gaddafi paid $2.7bn (£1.8bn) in compensation to the victims' families – $10m for every victim. The final payment was made this year. US lawyers took approximately a third of the final amount. But the economic and humanitarian price for Libya was far higher: UN sanctions over an 11-year period inflicted billions of dollars' worth of economic damage on Libya and prevented thousands of Libyan citizens from travelling abroad.

The central pillar of the prosecution's case was that Megrahi wrapped the bomb in clothes before checking it on to a plane in Malta without boarding it himself. The bomb, the prosecution alleged, was subsequently transferred at Frankfurt on to the flight to London, and then loaded on to the flight to New York. Two years after the bombing, Granada TV ran a programme about the bombing featuring a dramatic reconstruction, in which a bag containing a bomb was loaded on to an Air Malta flight by a sinister-looking Arab, who then sloped off without boarding. Upset by the damage to its reputation, Air Malta sued Granada TV. The airline's solicitors compiled a dossier of evidence demonstrating that all the bags checked on to that flight were accompanied by passengers and none travelled on to London. The evidence was so convincing that Granada settled out of court.

Since the Crown never had much of a case against Megrahi, it was no surprise when the Scottish Criminal Cases Review Commission (SCCRC) found prima facie evidence in June 2007 that Megrahi had suffered a miscarriage of justice and recommended that he be granted a second appeal.

For 11 years, while legal proceedings were pending and throughout the trial, the British Government argued that a public inquiry into Lockerbie was not appropriate as it would prejudice legal proceedings. After the conviction, it switched tack, arguing instead that no public inquiry was necessary. But if the conviction were overturned, there would no longer be a reason to hold back. For Megrahi, this cannot come soon enough. In September he was diagnosed with advanced terminal prostate cancer.

The British Government is preparing for Megrahi to be transferred to Libya for the rest of his sentence. This would eliminate the risk of an acquittal and lessen the chance of a subsequent inquiry. Applications for a transfer cannot be submitted while an appeal is pending, which for the Government raises the convenient prospect that Megrahi will abandon his appeal so he can die at home. But letting Megrahi die a condemned man reduces the chance of Scottish prosecutors, the police, various UK intelligence services plus many American and other foreign bodies being asked a lot of difficult questions. Last month, a general agreement on the exchange of prisoners was signed between Libya and Britain paving the way for such a transfer. The agreement will be ratified in January.

"The Crown and the prosecution are using every delaying tactic in the book to close off every route available to Megrahi except prisoner transfer, as this means he has to abandon his appeal," commented Professor Robert Black QC, the Scottish lawyer who was the architect of the original trial who feels partly responsible for the miscarriage that occurred. "It is an absolute disgrace. It was 27 June 2007 when the SCCRC released its report and sent its case back to the criminal appeal court, and here we are 18 months later and the Crown has still not handed over all of the material that the law requires it to hand over and it is still making every objection conceivable."

There are, however, two obstacles to the British plan. Firstly, the decision to transfer Megrahi lies with the Scottish First Minister, Alex Salmond. Upset that the Government reached an agreement over Megrahi without consulting him first, Mr Salmond has ruled out any transfer.

Secondly, whether Megrahi dies in jail in Scotland or Libya, under Scottish law his appeal can still go ahead without him. "Any interested person can continue the case. In this case one of Megrahi's children could continue with the appeal to clear their father's name," says Professor Black.

If Megrahi didn't do it, who did? Some time ago suspicion fell on a gang headed by a convicted Palestinian terrorist named Abu Talb and a Jordanian triple agent named Marwan Abdel Razzaq Khreesat. Both were Iranian agents; Khreesat was also on the CIA payroll. Abu Talb was given lifelong immunity from prosecution in exchange for his evidence at the Lockerbie trial; Marwan Khreesat was released for lack of evidence by German police even though a barometric timer of the type used to detonate the bomb on Pan Am Flight 103 was found in his car when he was arrested.

Three months after the bombing, Dumfries and Galloway police published a report on Lockerbie that concluded: "There can be little doubt that Khreesat is the bomb-maker for the [Palestinian group] PFLP-GC, and there is a possibility he prepared the explosive device which destroyed Pan Am Flight 103. As such he should not be at liberty."

Not surprisingly, given the amount of skulduggery that has swirled around Lockerbie over the past 20 years, conspiracy theories related to the case have bloomed. Some believe that the CIA deliberately framed Libya so Syria would fight in the first Gulf War. Others suspect Lockerbie to be linked to drug smuggling, arms shipments and Iranian hostage negotiations.

Short of an unexpected confession, Lockerbie will likely remain one of those great, unsolved political whodunnits, like the assassination of JFK.

The fate of Abdelbaset al-Megrahi, however, and the tarnished reputation of the Scottish criminal justice system rest in the hand of the Scottish courts. Megrahi's acquittal, posthumous or otherwise, will undo a heinous wrong and return us to where we were 20 years ago – searching for the truth behind the bombing of Pan Am flight 103.

Hugh Miles is the author of 'Playing Cards in Cairo' www.hughmiles.com