While defense lawyers have argued in other terrorism cases that their clients had been entrapped by the police, this was the first time that a Canadian court accepted the claim. “The world has enough terrorists,” Justice Bruce wrote. “We do not need the police to create more out of marginalized people.”

The couple were convicted last year of three terrorism-related charges. Under Canadian law, entrapment arguments are heard only after a guilty verdict. The decision by Justice Bruce allowed her to issue a stay of proceedings, essentially ending the legal action. While technically not an acquittal, it leaves Mr. Nuttall and Ms. Korody without criminal records.

The couple, who said they were converts to Islam, came to the attention of the police initially after a neighbor complained that Mr. Nuttall was making violent “Islamic” statements. Although he had a record of petty crime, violence and drugs, when the police investigated the complaints they usually found them groundless and that Mr. Nuttall was under the influence of drugs or alcohol. Some officers and health officials said they were concerned that he appeared to be mentally unstable.

For reasons that are not clear, the couple were placed under surveillance.

The police learned that they rarely traveled beyond a four-block radius of their basement apartment. The couple reportedly drank to excess, used drugs and played video games and paintball for long periods.

Despite the lack of any indication that they were plotting criminal acts, the police started an undercover operation in which officers posed as members of a terrorist group and befriended the couple. The plan was approved by the police force’s national headquarters.