In a statement after the new charge was laid Tuesday, the RCMP said the arrest followed an “extensive” investigation dubbed “Project Swap” that began last August amid suspicion that Mohamed had travelled to Turkey in April 2014 to join Jabhat Al-Nusra, a listed terrorist entity in Canada. Mohamed returned to Canada a month later, police allege.

“We were able to not only disrupt this threat to our country’s national security, but also to bring this individual before the Canadian justice system,” the Mounties said in the statement.

“At no time during the course of this investigation was there any risk to public safety.”

Police allege Mohamed committed the offences in Ontario, including in the cities of Whitby, Mississauga and Waterloo, over a period from April 24, 2014 to March 25, 2016.

Mohamed was arrested Friday in Waterloo, Ont., under a recent law that essentially allows detention without charge. Police also charged him with two minor weapons offences related to his alleged possession of a hunting knife.

He watched closely but said little during the five-minute appearance in which he appeared in handcuffs before being led back to jail.

Afterward, defence lawyer Anser Farooq said his client had been brought to court Tuesday expecting to sign a peace bond and get released; his father had brought him fresh clothes. Instead Mohamed found himself charged with a crime that carries a maximum 10 years in prison.

Farooq said he had little idea of what evidence police might have to back up their allegations but said he hoped to know more next week. He also said he saw little reason Mohamed should not be able to win bail.

In an earlier statement Saturday, the RCMP said the preventative arrest, which required consent of Canada’s justice minister, stressed there was no imminent threat to public safety.

“While there was no indication of any plans for a domestic attack, we must remain committed to preventing individuals from travelling abroad to gain training and expertise that could be used in the planning and implementation of future attacks on Canadian soil,” said Supt. Lise Crouch.

The preventative detention law under which Mohamed was initially held was brought in last year by the former Conservative government in a bill known as C-51, which sparked widespread criticism from legal and civil-liberties groups, in particular for the extra powers it granted security forces.

The legislation gave Canada’s spy service the power to disrupt suspected terrorist plots, even when its court-approved actions breach the Charter of Rights and Freedoms.

Since then, security forces have used the new law on several occasions. They include the arrest of Aaron Driver in suburban Winnipeg last June and Ismael Habib, of Montreal, in February, who was later charged with a terror-related offence. Others have also been arrested under the provision in Montreal and Prince Edward Island.

The new Liberal government under Justin Trudeau has promised to repeal “problematic” elements of the law.