New Zealand spy agencies received intelligence from individuals detained and tortured by the CIA in Afghanistan during the 2000s, and in one case provided the CIA with a question for a detainee, a report from the Inspector-General has found.
But the spy agency watchdog cleared both the SIS and GCSB of being complicit or involved in the torture or ill-treatment of detainees in the CIA programme, which was established by the United States as part of its response to the 9/11 bombings.
A report from the Inspector-General of Intelligence and Security has found the New Zealand agencies were not aware some of the information they received had been gained through torture, although they did know it came from individuals being detained in secret locations.
The investigation began in 2015 following a highly critical report from the US Senate Committee on Intelligence into the CIA's activities in Afghanistan, some of which was found to have amounted to torture.
The Inspector-General found both agencies - but to a much greater degree the SIS - received many intelligence reports obtained from detainees who had been tortured.
The Inspector-General said the CIA's activities in Afghanistan involved abuse that was "unlawful in New Zealand and at international law and amounted to torture".
"It also involved the unlawful transportation, or "rendition", of detainees to and from Afghanistan to other countries for interrogation."
The programme was put in place as part of the US response to the 9/11 bombings.
Acting Inspector-General Madeleine Laracy said the inquiry examined the role of the New Zealand intelligence agencies and whether they had any connection to the CIA's "enhanced interrogation", detention and rendition programme in Afghanistan between 2001 and 2009.
It also considered whether their policies and guidance "were and are adequate to deal with the complex legal and ethical obligations that arise when engaging cooperatively with foreign counterparts".
"The NZSIS and the GCSB had lines of connection to the CIA, but they were not complicit or otherwise involved in torture or ill-treatment of detainees", the inquiry concluded.
The inquiry found while the SIS did not know about the torture, it did know individuals were being held by the CIA in secret locations.
On one occasion the NZSIS provided questions to the CIA to be put to a detainee, the report said.
And it warned New Zealand agencies needed to be very aware of the risks when sharing intelligence, and of the human rights implications.
"It was considered that the directors of the agencies at the time were operating in a difficult political and intelligence environment but still needed to be more alive to the risks for their agencies and New Zealand in maintaining cooperative information sharing arrangements.
"The Inspector-General also notes ... the former directors carried out their roles with professionalism and integrity", the report said.
It found agency staff, particularly those from the GCSB who were deployed to Afghanistan, "lacked adequate training and support".
The report's recommendations relate to the agencies' current human rights policies affecting all of its information sharing and cooperation with foreign agencies.
They include the need for the agencies to have a clear mandate at ministerial level for activities with overseas partners that might involve legal or reputational risk, and that when supporting military deployments intelligence agency staff need to be comprehensively trained to identify where human rights issues might arise.
Both agencies say they will look at disposing of, or sealing, any intelligence reports received from the CIA as a result of torture.
The SIS and GCSB welcomed the report and its finding that there was no direct involvement in the CIA and no complicity in any unlawful conduct.
GCSB director-general Andrew Hampton said the findings were "testament to the professionalism, integrity and good judgement of the GCSB staff who provided intelligence support to New Zealand's military deployment to Afghanistan".
But he acknowledged the need for improvement in the support, training and supervision of deployed staff.
"GCSB staff who go on deployment in support of New Zealand's military make personal sacrifices to serve their country, and they deserve the best support, guidance and training we can give them.
"I have met with the GCSB staff who were deployed during this period.
"We discussed the Inspector-General's findings and their experiences and I asked them to give me any further suggestions on how any future guidance and support could be improved."
The legal framework under which the agencies operated has also had a significant overhaul since the inquiry started, in a 2017 law change.
"All co-operation with international intelligence partners is governed by New Zealand law, including human rights obligations", Mr Hampton said.
And he said an cooperation with foreign intelligence agencies now needed to be in accordance with a Ministerial Policy Statement issued by the Minister Responsible for the GCSB and NZSIS, which included completing human rights assessments of those countries.
SIS director-general Rebecca Kitteridge said staff put "significant effort" into ensuring the Inspector-General had access to all relevant information, and was pleased with the findings.
She too reiterated the Inspector-General's report dealt with events that took place between 10 and 15 years ago, and the agency now operates under Intelligence and Security Act 2017, which set out a "a clear framework for co-operation between the New Zealand intelligence agencies and the intelligence agencies of other countries, and for how we can support New Zealand military engagements overseas".
The SIS would now identify the relevant reports and make them inaccessible to staff, while a decision was made about what to with them in the longer term.