HMRC bosses failed to identify almost a third of MSPs as being Scottish taxpayers.

Jim Harra, the deputy chief executive of HMRC, said 45 of Holyrood’s 129 members had been issued with an incorrect code for 2019-20.

He said he was “not pleased to learn that the mistake had been made”.

Harra addressed the issue as he faced MSPs on Holyrood’s Public Audit Committee, and convener Jenny Marra told him she was one of those affected.

Harra said: “We identified 45 MSPs where we had sent them an incorrect 19-20 code which did not identify them as a Scottish taxpayer. That was because of a clerical error in the tax office that looks after the affairs of Scottish parliamentarians.”

Pressing him on the issue, Marra said: “For such a significant clerical error to happen with such a small group when there is a special process in place, that is the thing that really worries me about the confidence in the wider system.”

Harra said he shares such concerns, but added he is “satisfied” the issue would not have applied to the general population.

He said: “There is a special clerical process that applies to parliamentarians and that is what went wrong.

“The process for the main bulk of the population is an automated one, based on the address.”

However he also told the committee HMRC had to correct some 30,000 self-assessment tax returns after people failed to identify themselves as Scottish taxpayers.

“The error rate is too high,” he conceded.

A tick box was included in the form for people to say if they are a Scottish taxpayer.

HMRC had initially based its calculations on what people put on the form, but Harra said: “We quickly learned the level of error in returns was such that it was actually better to calculate the level of tax based on what we knew from our own database.”