Kenny MacAskill's full speech at the time of Al Megrahi's release explains rather eloquently what the Scottish law is and why the action was taken.
The end bit sums it up nicely:
Scotland will forever remember the crime that has been perpetrated against our people and those from many other lands. The pain and suffering will remain forever. Some hurt can never heal. Some scars can never fade.
Those who have been bereaved cannot be expected to forget, let alone forgive. Their pain runs deep and the wounds remain.
However, Mr Al Megrahi now faces a sentence imposed by a higher power. It is one that no court, in any jurisdiction, in any land, could revoke or overrule. It is terminal, final and irrevocable. He is going to die.
In Scotland, we are a people who pride ourselves on our humanity.
It is viewed as a defining characteristic of Scotland and the Scottish people.
The perpetration of an atrocity and outrage cannot and should not be a basis for losing sight of who we are, the values we seek to uphold, and the faith and beliefs by which we seek to live.
Mr Al Megrahi did not show his victims any comfort or compassion. They were not allowed to return to the bosom of their families to see out their lives, let alone their dying days. No compassion was shown by him to them.
But that alone is not a reason for us to deny compassion to him and his family in his final days.
Our justice system demands that judgement be imposed but compassion be available.
Our beliefs dictate that justice be served, but mercy be shown.
Compassion and mercy are about upholding the beliefs that we seek to live by, remaining true to our values as a people. No matter the severity of the provocation or the atrocity perpetrated.
For these reasons – and these reasons alone – it is my decision that Mr Abdelbaset Ali Mohmed Al Megrahi, convicted in 2001 for the Lockerbie bombing, now terminally ill with prostate cancer, be released on compassionate grounds and allowed to return to Libya to die.