Sting operations — in which an undercover agent or informant provides the means and opportunity to lure otherwise incapable people into committing a crime — have represented the default tactic for counterterrorism prosecutions since the 9/11 attacks.

Critics believe these stings amount to entrapment. Human Rights Watch, for instance, argues that law enforcement authorities in the U.S. have overstepped their role by “effectively participating in developing terrorism plots.” Nonetheless, U.S. courts have rejected entrapment defenses, no matter how hapless the defendants.

In Canada, however, the legal standing of counterterrorism stings has suddenly shifted. Last week, a high-ranking judge in British Columbia stayed the convictions of two alleged terrorists, ruling that they had been “skillfully manipulated” and entrapped by an elaborate sting operation organized by the Royal Canadian Mounted Police.

“The specter of the defendants serving a life sentence for a crime that the police manufactured by exploiting their vulnerabilities, by instilling fear that they would be killed if they backed out, and by quashing all doubts they had in the religious justifications for the crime, is offensive to our concept of fundamental justice,” the judge wrote. “Simply put, the world has enough terrorists. We do not need the police to create more out of marginalized people who have neither the capacity nor sufficient motivation to do it themselves.”

This is the first time that a counterterrorism sting — whose tactics were developed by the FBI through modifying those of undercover drug stings — has been thrown out of court whole cloth in Canada or the U.S.

Supreme Court Justice Catherine J. Bruce was ruling in the case of John Nuttall and his common-law wife, Amanda Korody, two drug addicts who lived on the streets in British Columbia. As part of a sting operation in which the RCMP paid at least 200 officers a total of more than 900,000 Canadian dollars in overtime, law-enforcement agents encouraged the couple to place pressure-cooker bombs at the British Columbia parliament building on Canada Day 2013.

As in FBI counterterrorism stings, RCMP provided Nuttall and Korody with everything they needed to become terrorists. In addition, as a result of frustrations that Nuttall would not commit to a feasible plot, the undercover Mounties offered inducements for him to move forward, including showing him CA$20,000 in cash.

In June 2015, the couple were found guilty and faced possible life sentences. But the convictions were not entered, pending a judicial review of whether RCMP had entrapped the couple. Bruce ruled that in fact they had been entrapped.

The case of Nuttall and Korody is striking for its similarities to counterterrorism stings in the United States. The FBI has arrested, and the Department of Justice has prosecuted, dozens of people who share Nuttall’s and Korody’s traits: broke, no connections to terrorists, and of questionable capacity and mental state.

In the United States, where a new FBI counterterrorism sting is announced every few weeks, more than 200 people have been convicted based on undercover counterterrorism stings since the 9/11 attacks.

The so-called Newburgh Four, a group of poor and unsophisticated men who plotted with an FBI undercover informant to bomb synagogues in the Bronx, were convicted even after trial evidence revealed the government informant had offered them $250,000 to participate in the plot.

Abu Khalid Abdul-Latif, who had a history of suicide attempts, and Walli Mujahidh, who was diagnosed with schizoaffective disorder, were convicted of planning to attack a military recruiting station near Seattle as part of a plot led by FBI informant Robert Childs, a convicted child molester.

Kosovo-born Sami Osmakac, a broke man in Tampa who was also diagnosed with schizoaffective disorder, is serving 40 years in prison for his part in an FBI plot to bomb a local bar and attack a casino. He was convicted after FBI agents described him in accidentally recorded conversations as a “retarded fool” who doesn’t have “a pot to piss in.”

There are many more examples.

While Abdul-Latif and Mujahidh pleaded guilty to their charges, the Newburgh Four and Osmakac argued entrapment at trial. They joined about a dozen others who have tried a similar defense following counterterrorism stings. None has been successful in U.S. courts.

In recent months, FBI officials have commented publicly about plans to increase counterterrorism stings, despite the fact that the FBI’s dragnet has been ineffective at catching, among others, Boston Marathon bomber Tamerlan Tsarnaev and Orlando nightclub shooter Omar Mateen.