A top civil servant who became embroiled in a row after advice he gave against a currency union ahead of the independence referendum was published has stepped down after ten years.

Sir Nicholas Macpherson, who was permanent secretary to the treasury, published his advice to UK Government ministers on a possible currency union with an independent Scotland in 2014, sparking an angry reaction from the First Minister Alex Salmond.

The currency issue had formed a central part of the debate over whether Scotland would be better off as a separate country to the UK, and Tory chancellor George Osborne ruled out a deal after Sir Nicholas' advice.

He told Mr Osborne such an arrangement could be "fraught with difficulty" and raised concerns about the Scottish Government's commitment to making such a deal work.

Mr Salmond called for his resignation in March last year after a probe by MPs questioned his "perceived impartiality".

Sir Nicholas was criticised by the Commons Public Administration Select Committee, who said his advice was only made public "because it suited ministers' political objectives in respect of the Scottish referendum".

But he defended the action n a speech this year, saying he published the advice "because I regarded it as my duty".

He confirmed he will step down in March after more than 10 years in the role and leave the civil service.

The civil servant, who in the Queen's Birthday Honours list last summer, was appointed permanent secretary in August 2005 following the departure of Sir Gus O' Donnell.

Mr Macpherson said: "It has been a privilege to lead the Treasury through an extraordinary period. But after 31 years in the department, and having worked on 33 Budgets and 20 Spending Reviews, it is time to do something else while I still can.

"With the fiscal strategy for this Parliament set and the economic recovery well established, now is the right time to stand aside and for someone else to guide the Treasury through the challenges ahead.

"I pay tribute to the remarkable energy, creativity, resilience and decency of the Treasury ministers and officials I have worked with."

Cabinet secretary Sir Jeremy Heywood said: "Nick has had a remarkable career in the Civil Service, providing robust advice to successive governments, without fear or favour, for three decades on some of the most difficult and important issues faced by the country.

"In addition, as permanent secretary for the last ten years Nick has provided tremendous leadership to the Treasury, with his consistency, strength and insight helping to guide the institution through some of the most significant challenges in its history.

"On a personal note I would like to thank Nick for the unwavering support he has given me as Cabinet Secretary and for the massive contribution he has made over the years to maintaining the values, integrity and professionalism of the Civil Service."