SNP ministers looked into scrapping the contract to run the 2011 census after the private firm involved was linked to torture in Iraq, official documents have revealed.

The Scottish Cabinet feared there was a “significant risk” that a boycott could undermine the once-in-a-decade household survey.

Then finance secretary John Swinney was tasked with an “urgent” review of all options, “including the potential option of terminating the contract”, using legal action if necessary.

The discussion is disclosed in Scottish cabinet minutes from the summer of 2008 released by the National Records of Scotland under its 15-year rule.

It followed reports in Sunday Herald about  the Scottish Government hiring CACI UK to run the census and process the returns under a contract worth £18.5m.

The firm was a subsidiary of US-based military contractor CACI International, which supplied interrogators to the infamous Abu Ghraib prison in Iraq.

The prison became notorious in 2004, a year after the US-led invasion of Iraq, when sickening images emerged of US soldiers abusing inmates, including detainees cowering from dogs.

CACI was sued in 2008 by former inmates who alleged its personnel had been complicit in the torture, an accusation CACI vehemently denies. The case is still going through US court.

When it emerged in 2008 that a CACI subsidiary was involved in running Scotland’s census, the SNP Government was urged to cut its links to the firm.

Then Labour MP Mohammad Sarwar said the contract had “damaged the credibility of the SNP with all communities in Scotland, particularly the Muslim community", and the Stop The War Coalition set up a petition on the issue.

There were also concerns about census data being shared with the US Government via CACI under American anti-terrorism legislation passed in the wake of the 9/11 attacks.

In public, the Scottish Government said the issue was for the then General Register Office of Scotland to handle, as it had signed the contract with CACI UK.

However behind the scenes, SNP ministers took an active interest in the matter.

Minutes of the Scottish cabinet of 26 August 2008 show the census contract was discussed as a separate item, with Mr Swinney highlighting recent media reports.

The minutes record: “The contract for carrying out the census in Scotland had been awarded separately from the contracts for other parts of the UK, and had been won by CACI UK, a UK subsidiary of the American firm CACI International.

“Reports in the media suggested that a campaign was being mounted to boycott the census, particularly within the Muslim community in Scotland, which had voiced objections to the award of the contract to CACI, both on the grounds of the American parent company's association with the Abu Ghraib camp in Iraq and a broader concern that provisions in the American Patriots' Act 2001 appeared to give the US government powers to request personal data held by American companies and their subsidiaries. 

“Media reports had suggested that this could, therefore lead to personal data provided for the census being passed to the US government.

“Mr Swinney said that the award of the contract to CACI UK had been carried out in accordance with EU procurement law and due procedures.”

The next six lines of the minutes are redacted. 

They then continue: “He said that decisions about the way forward would need to be taken quickly, as the timescales for the roll-out of the census were tight. 

“The cabinet agreed that:

(a) the possibility of a boycott campaign represented a significant risk to the validity and integrity of the census; and that

(b) Mr Swinney should give detailed and urgent consideration to all the available options to ensure the validity and integrity of the census, including the potential option of terminating the contract with CACI UK, by mutual consent or through legal action, and the identification of an alternative supplier.” 

At the next cabinet on 2 September, Mr Swinney said he had received further advice from the Registrar General and would brief the First Minister and deputy FM that week.

Later minutes do not record the outcome, however CACI UK retained the contract and ran the census as agreed, despite campaigners continuing to urge a boycott.