The ex-head of Canada's federal police intelligence unit, accused of leaking secrets, said he was acting on a foreign agency tip about a "grave threat," according to a transcript released Friday.

Cameron Ortis, 51, was the director general of the Royal Canadian Mounted Police (RCMP) national intelligence coordination unit until his arrest in September 2020.

He has pleaded not guilty to charges that convulsed the national security and intelligence community of trying to sell sensitive secrets from Canada and the powerful Five Eyes intelligence alliance -- which also includes Australia, the United States, Britain and New Zealand -- to individuals linked to criminal groups.

According to redacted transcripts of his video testimony, Ortis told the court he was contacted in the fall of 2014 by a counterpart at a foreign agency, which was not named.

He said he was briefed about an online encrypted service called Tutanota set up by the agency explicitly for use by criminal targets in order to eavesdrop on their communications.

He was also provided with information about a threat to Canada, which he did not detail, but claimed to have corroborated by checking intelligence and police files.

"It was very compelling, and it demonstrated clearly a direct and grave threat," Ortis said.

He testified also that he was instructed by his counterpart "not to share the information with anyone."

Ortis said he decided to secretly act on it, and hatched a plan to try to get Vincent Ramos -- the chief executive of Phantom Secure Communications, a Canadian company that provided encrypted mobile phones to transnational crime groups -- and three others to start using Tutanota.

"Ultimately the plan was mine," he said.

Ortis said he reached out to Ramos to try to sell him top secret intelligence documents, as a way to lure him into using Tutanota.

The prosecution and defense agree that Ortis sold secrets to Ramos, the jury is to decide whether he did so with authority.

Other witnesses, including Ortis's former boss RCMP assistant commissioner Todd Shean, have testified that Ortis was never meant to go undercover or reach out to targets of police investigations.

Authorities got wind of his alleged crimes through a separate investigation of Phantom Secure Communications.

RCMP documents eventually linked to Ortis were found on the laptop of Ramos, who has been jailed for racketeering in the United States.