A LEGAL loophole that allowed prisoners serving life sentences to be released on parole earlier than those serving fixed-length terms is to be closed.

MSPs voted for change after the appeal court cut the minimum term to be served by Edinburgh paedophile gang member Morris Petch, and halved the minimum term of Robert Foye, who raped a schoolgirl while on the run from prison.

Appeal court judges had called for new legislation.

As the law stood, they said, there were cases where the punishment part of a sentence which life prisoners must serve before applying for parole was shorter than the amount of time those on fixed-term sentences had to serve.

Justice Secretary Kenny MacAskill said Holyrood's decision to back the Criminal Cases (Punishment and Review) (Scotland) Bill tackled an "absurd situation".

Judges will now regain the discretion to set a punishment part of sentences.

Mr MacAskill said: "Appeal judges ... called on the Scottish Parliament to intervene with a clear, well-considered legislative solution and we have quickly responded."

He said it closed a loophole caused by the judgments which created "an absurd situation where prisoners serving life sentences were able to qualify for parole earlier than those not serving life".

He added: "Parole should not be considered for prisoners who have not fulfilled what the court deems to be an adequate period of punishment."

The appeals by Petch and Foye challenged how courts calculated the time prisoners given discretionary life sentences had to wait before they could ask the parole board to free them.

It applied to rapists, paedophiles and other dangerous criminals handed discretionary life sentences, but not murderers, whose life sentences are mandatory.

The appeal court judges ruled life prisoners should be allowed to apply for parole after serving half of their sentence, after taking out a public protection element.

In comparison, fixed terms include a period thought to be necessary for the protection of the public.

This difference led to the loophole.

The Bill, which is not retrospective, will now give courts the discretion to set the punishment part for discretionary life sentences or an Order for Lifelong Restriction (OLR), which provides for the lifelong supervision of high-risk violent and sexual offenders.

Mr MacAskill said no prisoner had been released from prison as a result of the judgments.

But he added: "However, the pain and suffering caused, particularly to victims and their families when they hear that courts are not able to punish serious offenders appropriately can be deeply traumatic and I hope this legislation will bring reassurance that public safety is the absolute priority."

The second part of the Bill was intended to permit the publication of the statement of reasons for permitting Abdelbaset Ali Mohmed al Megrahi to appeal against his conviction for the Lockerbie bombing.

However, following the publication of the statement by the Sunday Herald, this is widely regarded as redundant.