Scottish ministers are drawing up their own legislation to exonerate the victims of the Post Office Horizon scandal after the UK Government suggested Westminster laws may not be workable north of the Border.

Scottish First Minister Humza Yousaf said he believes the “easiest and quickest route” would be for legislation being brought forward by the UK Government to clear the names of those who suffered a miscarriage of justice to apply in Scotland as well.

But with the issue of justice devolved, he told MSPs “there are complexities to work through” for that to happen.

His comments came as a UK Government source stressed the “need to avoid unrealistic expectations that Westminster will simply legislate on Holyrood’s behalf”.

Read more: Lord Advocate apologises to those ‘failed’ in Horizon scandal

The source said: “This is a hugely complex area and it might not be possible or the best way forward.

“It was reassuring to hear from the First Minister that the Scottish Government is actively drawing up Holyrood legislation.

“It may be that’s the most appropriate solution and in that event the two Governments will work closely to ensure compensation can be paid to victims across the whole UK.”

But the Scottish Government's most senior civil servant, permanent secretary John-Paul Marks, has suggested that Holyrood could be open to compensation claims from victims if the Scottish parliament legislates to redress prosecutions.

Asked at Holyrood's Public Audit Committee if money would need to be found if the UK compensation scheme wasn’t available to Scots victims, Mr Marks said: “Yeah, we’ll need to just confirm the accounting of how that would work given the way the compensation scheme has been set up, the nature of how that would be accessed.”

The comments come in the wake of Mr Yousaf saying he had received a “positive” response after writing to Prime Minister Rishi Sunak on the issue, while making clear the Scottish Government is already looking at “contingencies” which could see it bring forward its own legislation.

But the letter from Mr Sunak does not mention the UK legislation applying in Scotland, but points to “productive discussions” and finding the “right path” to justice in Scotland.

Mr Sunak stressed “the UK Government is committed to working with devolved administrations to ensure that all subpostmasters irrespective of location receive the exoneration they deserve”, with the Prime Minister also recognising the “shared will to right the wrongs of the past”.

Read more: Horizon scandal: MSPs told Post Office acted 'like the mob'

He went on to say Scottish Justice Secretary Angela Constance and her UK counterpart Alex Chalk will have “productive discussions” on the matter.

“The right path to providing justice for victims in Scotland will be found,” the Prime Minister said.

More than 700 Post Office managers across the UK were convicted after the faulty Horizon accounting software, made by Fujitsu, made it look like money was missing from branches.

Mr Sunak declared last week they were victims of “one of the greatest miscarriages of justice in our nation’s history”, as he announced a law will be introduced to exonerate them.

Mr Yousaf said he welcomed that approach and reiterated the Scottish Government is “willing to work with the UK Government for that legislation to take place and have effect on a UK-wide basis”.

That could be achieved through a legislative consent motion (LCM), which sees a devolved government formally agree to allow Westminster to legislate in an area where it has responsibility.

Read more: SNP MP demands mortgage prisoner action after 'collusion' claim

Mr Yousaf said this would be his “preference”, but in an effort to give clarity to “subpostmasters, subpostmistresses right across Scotland”, he said the Scottish Government will bring forward its own legislation if that could not happen.

Speaking at First Minister’s Questions, he said: “The UK Government last week announced they were looking to bring forward legislation in the UK Parliament in order for mass exonerations to take place when it comes to wrongful convictions.

“I have written to the Prime Minister to say we welcome that process and, not only that, as the First Minister we would be willing to work with the UK Government for that legislation to take place and have effect on a UK-wide basis.”

He added that if “for whatever reason” an LCM is not possible, “we are already working on contingencies around separate Scottish legislation if that is required”.

But Mr Yousaf said he hopes that will not be necessary.

Scottish Conservative leader Douglas Ross meanwhile raised concerns that those affected north of the border could have to wait “far, far longer” for convictions to be quashed.

He noted that Scotland’s most senior prosecutor, Lord Advocate Dorothy Bain KC, had told MSPs on Tuesday there already is an “established route” for appeals in Scotland and that “each case must be considered carefully”.

Mr Ross said: “This matters here in Holyrood because the Crown Office is a devolved institution. The procedure by which these convictions can be quashed will be set by this Government and this Parliament.

“But the process set out by the Lord Advocate could see that taking far, far longer in Scotland than it should.”

Mr Yousaf said the Lord Advocate had been speaking in her role as the independent head of prosecutions in Scotland – saying this is separate from her position as legal adviser to the Scottish Government.

He again insisted: “It is still my preference that legislation is applied on a UK-wide basis through an LCM, I think that would be the preferable route.”