Megrahi is serving life for the bombing which killed 270 people
A "compelling case" exists for releasing the cancer-stricken Lockerbie bomber on bail pending his appeal, a court has heard.
Appeal judges in Edinburgh were told Abdelbaset Ali Mohmed Al Megrahi is terminally ill and should be released on compassionate grounds.
However, prosecutors argued the gravity of the offences means he should remain in jail.
A decision on whether he will be released will be taken later.
Al Megrahi's defence team at the Court of Criminal Appeal in Edinburgh said the former Libyan intelligence agent, diagnosed with prostate cancer, should be released in order to reside with his family in Scotland while receiving medical treatment.
Maggie Scott QC said the gravity of the offences Al Megrahi was convicted of - the murder of 270 people in the 1988 atrocity - was not sufficient reason to oppose bail.
In applying for interim bail, she referred to Al Megrahi's forthcoming appeal. This, she said, was an appeal of "substance" which could result in his conviction being overturned.
The defence QC also pointed to delays in holding the appeal and adding that Al Megrahi's liberty had been restricted for more than 17 years.
The court heard Al Megrahi was married and had five children aged between 10 and 25 and two grandchildren.
She added that his family had moved to Glasgow and had visas to visit and reside in Scotland.
"If released on bail the appellant would reside with his family," Ms Scott added.
She added that Al Megrahi was not considered a "flight risk".
"There is no security issue in respect of granting interim liberation," she said.
The court heard Al Megrahi had been an inmate in the open part of HMP Greenock for some time and had been a lawful prisoner with no disciplinary record.
It also heard there were concerns about the "psychological well-being" of Al Megrahi.
This was related to the conviction, along with a deep-seated isolation from his friends, family and religion.
He was also suffering from stress following his cancer diagnosis, the court heard.
Ms Scott added that Al Megrahi's physical condition had also deteriorated and that the lack of privacy in prison was causing him "considerable distress".
It is more than five years since Al Megrahi's lawyers presented papers to the Scottish Criminal Cases Review Commission claiming his conviction for the murder of 270 people was unsafe.
That case reached the Appeal Court in June last year and since then has been bogged down by legal arguments.
Dr Jim Swire, whose daughter Flora was killed in the bombing, was in court for the hearing and afterwards said he was "disappointed" a decision had not been reached.
"It seems he has not got very long to live and therefore the decision needs to be made as urgently as possible," said Dr Swire.
"Personally, I don't think the verdict against him was ever justified and I remain convinced he was wrongly convicted," he added.