Tens of thousands of votes in the Holyrood election were rejected by the counting machines without any human adjudication, BBC Scotland has learned.

An investigation has established that the machines were programmed to reject some of the new style ballot papers automatically.

Here is the full response issued by the Scotland Office, which was responsible for the election, in relation to the programme's findings.

The allegation that the Scotland Office took the sole decision on auto-adjudication is completely untrue and without foundation. Decisions on the election were taken as part of a collective decision-making process by the Scottish Executive, Scotland Office, returning officers and other relevant stakeholders.

In the instance of auto-adjudication for the count on May 3, the decision was taken between returning officers and the e-counting provider. Returning officers agreed individual user agreements with the e-counting provider that set out how their count was to be conducted and retained the statutory responsibility for the count of ballot papers.

The Scotland Office did not, at any stage in the process, overrule those decisions or give instructions to the contrary.

It's therefore entirely wrong for Mr Carmichael or anyone else to claim returning officers did not have a say in the planning and execution of the May elections or that the Scotland Office alone made the decision on auto-adjudication during the e-count on May 3.

The Scotland Office is responsible for the election rules for rejecting ballot papers, as laid out in the Scottish Parliament (Elections etc.) Order 2007.

These rules apply to both manual and electronic counting of ballot papers and state the reasons why a ballot should be rejected if it does not bear the official marks, if votes are given for more than one candidate or party, if anything on the paper can identify the voter, or if they are unmarked or void for uncertainty.

These are the only reasons a ballot paper can be rejected and not counted and the regulations make no rule that ballot papers have to be visible at all points during the count.

The specification for the e-counting system was produced via the e-counting project board and agreed to and signed by returning officers. This is where the system to deal with papers was set out and is a responsibility for returning officers.