(CN) – The U.S. Border Patrol may have violated the First Amendment rights of two photographers who were prohibited from taking pictures at the Mexico border, a Ninth Circuit panel ruled Tuesday.

Siding with civil liberties and press freedom advocates, the panel concluded U.S. Customs and Border Protection policy that prohibits photos at border ports may be unconstitutional.

Concerned about vehicle emissions at the U.S.-Mexico border, environmental activist Ray Askins was taking photos of idling vehicles at the Calexico, California, port of entry in 2012. Border Patrol agents took his camera and deleted the photos.

Askins sued the government along with Christian Ramirez, a human rights advocate who said he experienced something similar after he took photos of male border agents frisking women at the San Ysidro border crossing, also in California.

A federal judge in San Diego dismissed the photographers’ First Amendment complaint, concluding the agents used the least restrictive means to protect U.S. sovereignty.

The photographers filed an amended complaint, which the judge also dismissed after concluding it was barred by the law of case doctrine.

Allowing photos “would allow comprehensive, long-term documentation of port procedures,” U.S. District Judge Thomas Whelan wrote in 2016.

“Such intimate familiarity with CBP patterns would be invaluable to drug cartels and smugglers seeking to violate the borders of the United States.”

Arguing before a Ninth Circuit panel this past February, attorney Mitra Ebadolahi from the ACLU said her clients knew they weren’t allowed to take photos of sensitive information.

“This is not about the right to enter into restricted areas and take whatever photographs you want,” Ebadolahi told the panel. “Everything that we’re talking about is visible out of doors.”

In a 23-page opinion issued Tuesday, the panel agreed the photographers may have a First Amendment claim that needs to be more fully vetted by the trial court.

The trial court was not precluded from considering the amended complaint, U.S. Circuit Judge Jay Bybee wrote for the panel, especially given the government defended Border Patrol policies “in conclusory fashion.”

He added: “These conclusions are too thin to justify judgment for the government on a motion to dismiss.

“Without question, protecting our territorial integrity is a compelling interest that could justify reasonable restrictions on speech activities at ports of entry. But the devil lies in the details.

“It is the government’s burden to prove that these specific restrictions are the least restrictive means available to further its compelling interest. They cannot do so through general assertions of national security, particularly where plaintiffs have alleged that CBP is restricting First Amendment activities in traditional public fora such as streets and sidewalks.”

On Twitter, Ebadolahi praised the decision but noted that the merits of the case must still be decided.

The case was remanded to trail court. U.S. Circuit Judge Marsha Berzon and U.S. District Judge Sharon Gleason, sitting by designation from the District of Alaska, joined Bybee’s opinion.