A judge in New Hampshire says evidence obtained by drug-sniffing dogs during last summer’s U.S. Customs and Border Protection checkpoints in Woodstock is not admissible in state courts.

The order throws the prosecution's cases against more than a dozen legal residents into question.

The ACLU of New Hampshire brought the lawsuit on behalf of 16 legal U.S. residents who were found to have small amounts of drugs in their possession during multi-day checkpoints by in the southbound lanes of Interstate 93 in Woodstock, roughly 90 miles from the Canadian border.

While federal Border Patrol agents made no arrests on immigration charges, Woodstock Police Department officers, who were on the scene, detained legal residents found to be in possession of small amounts of drugs.

The civil liberties group argued that the state's Constitution protects citizens from searches including those by drug-sniffing dogs, unless there is “reasonable suspicion” of a crime. The group motioned the court to suppress any evidence obtained during the canine searches.

During oral arguments in January in Plymouth District Court, lawyers for the state countered that the use of trained search dogs by federal agents was a valid tool for the detection of illegal drugs. Under the U.S. Constitution, they argued such searches were legal.

In his ruling, Judge Thomas Rappa writes, "this court finds that given the defendants in this matter are facing prosecution in state court for violations of state laws the constitutional protections of the New Hampshire Constitution should apply."

In a statement, Gilles Bissonnette, legal director for ACLU-NH, calls the decision "a victory for civil liberties."

"As the court ruled, these checkpoints flagrantly violated the New Hampshire Constitution and the fourth Amendment. (Customs and Border Protection) and the (Woodstock Police Department) searched and seized hundreds, if not thousands, of the individuals during the summer tourist season without any reasons to believe that these individuals had committed a crime. This is not how a free society works."

In addition to ruling prosecutors in these 16 cases can’t submit evidence obtained by drug sniffing dogs in state courts, Judge Rappa also wrote that he believes the checkpoints were unconstitutional because their primary purpose was not the enforcement of immigration violations, but that that it was the “detection and seizure of drugs.”

Citing a U.S. Supreme Court case, Rappa points to legal precedent that the primary purpose of a “motor vehicle checkpoint cannot be the random detection of criminal activity such as drug detection.”

“The New Hampshire and Federal Constitutions do not allow law enforcement to engage in a fishing expedition for criminal activity. Yet this is precisely what happened here,” writes Buzz Scherr, a professor of law from UNH School of Law and co-counsel on the case, in a joint statement with the ACLU-NH.

It isn’t clear if the New Hampshire Attorney General’s office will appeal the ruling to a higher court. Lawyers for the State didn’t immediately respond to a request for comment.

(This story was updated Friday with more reporting on the judge's order and statements from the ACLU's counsel.)