An email sent by the then British ambassador in Tripoli details how a prisoner transfer agreement would be signed once Libya “fulfils its promise” to buy an air defence system.

The disclosure is embarrassing for members of the then Labour government, which always insisted that Abdelbaset al-Megrahi’s release was not linked to commercial deals.

The email, which contained a briefing on the UK’s relations with Colonel Muammar Gaddafi’s regime, was sent on June 8 2008 by Sir Vincent Fean, the then UK ambassador, to Tony Blair’s private office, ahead of a visit soon after he stepped down as prime minister.

Mr Blair flew to Tripoli to meet Gaddafi on June 10, in a private jet provided by the dictator, one of at least six visits Mr Blair made to Libya after quitting Downing Street.

The briefing, which runs to 1,300 words, contains revealing details about how keen Britain was to do deals with Gaddafi. It also suggests that:

• the UK made it a key objective for Libya to invest its £80 billion sovereign wealth fund through the City of London

• the UK was privately critical of then President George Bush for “shooting the US in the foot” by continuing to put a block on Libyan assets in America, in the process scuppering business deals

• the Department for International Development was eager to use another Libyan fund worth £130 million to pay for schemes in Sierra Leone and other poverty-stricken countries.

The release of Megrahi in August 2009 caused a huge furore, with the Government insisting he had been released on compassionate grounds because he was suffering from terminal cancer, and that the decision was taken solely by the Scottish government.

Megrahi had been convicted in 2001 of the murder of 270 people when PanAm flight 103 from London to New York blew up over Lockerbie in Scotland in 1988. It remains Britain’s single worst terrorist atrocity.

Libya had been putting pressure on the UK to release Megrahi and in May 2007, just before he left Downing Street, Mr Blair travelled to Sirte to meet Gaddafi and Al-Baghdadi Ali al-Mahmoudi, Libya’s then prime minister.

At that meeting, according to Sir Vincent’s email, Mr Blair and Mr Baghdadi agreed that Libya would buy the missile defence system from MBDA, a weapons manufacturer part-owned by BAE Systems. The pair also signed a memorandum of understanding (MoU) for a prisoner transfer agreement (PTA), which the Libyans believed would pave the way for Megrahi’s release.

The British government initially intended the agreement to explicitly exclude Megrahi. However, ministers relented under pressure from Libya.

In December 2007, Jack Straw, then justice secretary, told his Scottish counterpart that he had been unable to secure an exclusion, but said any application to transfer Megrahi under the agreement would still have to be signed off by Scottish ministers.

With Mr Blair returning in June 2008 — as a guest of Gaddafi on his private jet — the government appears to have used the chance to press its case for the arms deal to be sealed. At the time, Britain was on the brink of an economic and banking crisis, and Libya, through the Libyan Investment Authority, had billions of pounds in reserves.

Sir Vincent gave Mr Blair’s office a briefing on the state of relations with Libya. The email suggests that Mr Blair was being used as a conduit.

Sir Vincent wrote: “There is one bilateral issue which I hope TB [Tony Blair] can raise, as a legacy issue. On 29 May 07 in Sirte, he and Libya’s PM agreed that Libya would buy an air defence system (Jernas) from the UK (MBDA). One year on, MBDA are now back in Tripoli (since 8 June) aiming to agree and sign the contract now — worth £400 million, and up to 2,000 jobs in the UK.

“Saif [Gaddafi’s son] says they are to come back to conclude; but there is opposition within the Libyan armed forces, from those in the Russian defence equipment camp. We think we have Col Q’s [Gaddafi’s] goodwill for this contract: it would be very helpful if he expressed it more clearly. This issue can also be raised with Libya’s PM, and the Planning Minister. It was PM Baghdadi who told the media on 29 May 07 that Libya would buy British.

“Linked (by Libya) is the issue of the 4 bilateral Justice agreements about which TB signed an MoU with Baghdadi on 29 May. The MoU says they will be negotiated within the year: they have been. They are all ready for signature in London as soon as Libya fulfils its promise on Jernas.”

The PTA was signed in November 2008 by Bill Rammell, a foreign office minister.

Megrahi was diagnosed with prostate cancer and released in August 2009 on compassionate grounds when he was given three months to live. He died in May 2012.

The Libyans never signed the arms deal, MBDA said yesterday. “MBDA operates, at all times, strictly within the limits of clearly defined export licensing regimes issued by the relevant Government authorities,” a spokesman said.

“All MBDA’s dealings with Libya were purely commercial and in accordance with the EU directive at the time.”

The disclosure of the email, which was obtained by The Sunday Telegraph as a result of a Freedom of Information request, angered the relatives of victims of the bombing.

Pam Dix, whose brother Peter died at Lockerbie, said: “It appears from this email that the British government was making a clear correlation between arms dealing with Libya and the signing of the prisoner transfer agreement.

“We were told Megrahi’s release was a matter strictly for the Scottish government but this shows the dirty dealing that was going on behind the scenes.”

Lord Mandelson, who was business secretary when Megrahi was released, said he was unaware of any possible links between commercial deals and negotiations over a release.

He said: “Based on the information that I was given at the time, I made clear the government’s position. I was not aware of the correspondence covered in this FOI request.”

Jack Straw, who negotiated the PTA, said no deals were done over Megrahi, and it was always a decision for the Scottish government.

The email from Sir Vincent also informed Mr Blair on the latest stage of Megrahi’s bid for release, and urged him to fend off any demands that he be sent back. By 2008, Megrahi was appealing against his conviction for mass murder.

“Col Q may very well raise Megrahi,” wrote Sir Vincent, “Saif [Gaddafi’s son] raised the case … last week. It is now before the Scottish Appeal Court and sub-judice.

“While the appeal is current, no request to invoke the PTA can be made in that case. Were the appeal to fail and a request for Megrahi’s return to Libya were to be made subsequently, it would be for Scottish ministers to decide on any such request — not a question for HMG [Her Majesty’s Government].”

A spokesman for Mr Blair said that the prisoner transfer agreements did not relate to Megrahi. The email, he added, did not show “that the UK government was trying to link the defence deal and Megrahi”.

He said: “Actually it shows the opposite — that any linkage was from the Libyan side.

“As far as we’re aware there was no linkage on the UK side. What the email in fact shows is that, consistent with what we have always said, it was made clear to the then Libyan leader that the release of Megarahi was a matter for Scotland and was not a matter for Her Majesty’s Government.

“As we’ve said before, the subjects of the conversations during Mr Blair’s occasional visits was [sic] primarily Africa, as Libya was for a time head of the African Union; but also the Middle East and how Libya should reform and open up.

“Of course the Libyans, as they always did, raised Megrahi. Mr Blair explained, as he always did, in office and out of it, that it was not a decision for the UK government but for the Scottish Executive [formerly the name for the Scottish government].”