Claims by Alex Salmond that the Treasury deliberately leaked details of Royal Bank of Scotland's plans to relocate its headquarters to London in the event of a Scottish vote for independence have been rejected by Whitehall's most senior civil servant.

The First Minister wrote to the Cabinet Secretary Sir Jeremy Heywood after the BBC reported the move - citing a Treasury source - accusing officials of leaking market sensitive information in a "deliberate attempt to cause uncertainty in the financial markets".

But in a letter last night to the First Minister, Sir Jeremy said that the Treasury had simply been confirming its understanding of RBS's plans after details appeared elsewhere in the media.

He said the the chain of events began with a report in The Sun at 10pm on Tuesday night reporting a statement from the Lloyds Banking Group making clear it had contingency plans to move its registered HQ out of Scotland in the event of a Yes vote.

Around the same time the newspaper said that an RBS source had said that RBS would almost certainly follow suit while the BBC was also reporting that it had been told - it was not clear from where - that a similar announcement from the bank might be imminent.

"It was clear to the Treasury that this was likely to generate significant interest in - and uncertainty about - an issue with important implications for financial stability. In response, therefore, the Treasury press office confirmed its understanding of RBS' contingency planning. RBS made a formal market announcement at 7am," Sir Jeremy wrote.

"This was not a UK Government announcement - it was simply a confirmation of the Treasury's understanding of RBS' contingency planning.

"In response to the Lloyds statement and informed media reports about RBS, the Treasury judged that it was important to set this out - at a time when the UK financial markets were closed - given their overarching responsibility for maintaining financial stability in the UK.

"I have consulted the PM to whom you have also written and he is clear that there has been no breach of the Ministerial Code."

In his letter to the Prime Minister, Mr Salmond demanded an explanation for what happened complaining that "your Treasury has been involved in trying to destabilise financial services in Scotland - all in an attempt to frighten voters in Scotland".

Writing to Sir Jeremy, he added: "The apparent role of the Treasury in colluding with the leaking of this inside information prior to markets opening is a serious matter in its own right.

"It is also hard to escape the conclusion that the motivation in this collusion was political - to secure an apparent news advantage in the referendum debate.

"If the Treasury source was a civil servant - mainline or special adviser - acting under instruction of a minister, this is a breach of the Ministerial Code."