EDINBURGH - A former Libyan agent jailed for life for the 1988 Lockerbie bombing that killed 270 people, most of them Americans, is to be freed on Thursday, the Scottish government said.

Abdel Basset al-Megrahi, who has terminal cancer, will return to Libya on compassionate grounds, despite pressure from the U.S. government to keep him in prison.

Megrahi now faces a sentence imposed by a higher power, Scottish justice minister Kenny MacAskill told a news conference. It is terminal, final and irrevocable. He is going to die.

A Libyan government spokesman said Megrahi was being flown home by a son of Libyan leader Muammar Gaddafi.

Megrahi has been released and is on his way home, the spokesman said.

Megrahi, 57, is the only person to be convicted over the bombing of Pan Am Flight 103 in mid-air above the Scottish town of Lockerbie. He lost an appeal against his conviction in 2002.

However, a Scottish review of his case ruled in 2007 that the case may have been a miscarriage of justice.

The United States and the relatives of many of the 189 American victims had opposed Megrahi's early release and said he should serve his full life sentence in prison.

The families of many of the Britons killed in the bombing thought he should be allowed to go home to die.

Megrahi is likely to be warmly welcomed by Gaddafi, who has moved closer to the Western mainstream since dropping his nuclear weapons programme in 2003.

The Megrahi case had become a millstone for the Scottish government as it balances a series of competing interests, among them the fact that British oil companies are trying to do more business in Libya and hope Megrahi's release might open doors.

British oil company BP ended a 30-year absence from Libya in 2007 when it signed its biggest exploration commitment through a bilateral deal. Royal Dutch Shell also wants to tap Libya's reserves, the biggest in Africa.

(Additional reporting by Ali Shuaib in Tripoli and Peter Griffiths and Matt Falloon in London; Editing by Richard Balmforth)