The Scottish Government has confirmed it has paid £512,250 in legal costs to Alex Salmond after a court ruled its handling of complaints made against him were “unlawful”.

The former first minister launched legal action against the Scottish Government in August 2018 to contest the complaints process activated against him in relation to sexual harassment allegations, which Mr Salmond has denied.

At a hearing at the Court of Session in Edinburgh in January, judge Lord Pentland said the Government’s actions had been “unlawful in respect that they were procedurally unfair” and had been “tainted with apparent bias”.

The Scottish Government admitted it had breached its own guidelines by appointing an investigating officer who had “prior involvement” in the case.

On Tuesday, a spokesman for the Scottish Government confirmed the cost of the final settlement.

He said: “We can confirm that final settlement of £512,250 has been made to Mr Salmond for legal costs arising from his petition for judicial review.”

A spokesman for the former first minister said: “The huge amounts which have been paid in legal expenses by the Scottish Government reflects the agreement by which the investigation of Mr Salmond was declared by the Court of Session as ‘unlawful’, ‘unfair’ and ‘tainted by apparent bias’.”

Money for the case was raised through a crowdfunding appeal and the spokesman added: “All Mr Salmond’s legal costs for the judicial review, including those not fully covered by the court expenses award, are in the process of being paid.

“When that is completed there is likely to still be a surplus in the crowdfunder which supported his application for judicial review.

“This will be independently audited and distributed to good causes in terms of the commitments previously given by Mr Salmond.”