BOSTON (CN) – A federal judge ruled Monday that the Massachusetts law barring the secret recording of government officials is unconstitutional.

The ruling was applied to a pair of First Amendment lawsuits from opposite ends of the political spectrum.

On one side were two local activists who sought more protections in their efforts to secretly record police officers, while on the other end was conservative activist James O’Keefe and his organization Project Veritas, which planned to secretly record Democratic public officials in order to embarrass them.

“On the core constitutional issue, the Court holds that secret audio recording of government officials,including law enforcement officials, performing their duties in public is protected by the First Amendment, subject only to reasonable time, place, and manner restrictions,” Chief U.S. District Judge Patti Saris wrote in a 44-page ruling.

The 1968 Massachusetts wiretap law criminalizes secret audio recordings, and has been used to arrest and prosecute people for secretly recording police officers performing their duties in public. Both the Boston Police Department and the Suffolk County District Attorney’s Office have pursued criminal action under the state law against individuals for secretly recording police officers performing their duties in public.

O’Keefe, who infamously caused the defunding of the liberal community-organizing group ACORN in 2009 through the use of edited hidden camera footage, wants to bring his organization Project Veritas to Boston to nab local politicians talking about its status as a sanctuary city.

Before his cameras could start rolling, Project Veritas unsuccessfully sought an injunction in 2016 against the Massachusetts wiretapping statute to avoid violating the law.

Despite losing the injunction, O’Keefe is now able to celebrate the court win.

“Project Veritas has made First Amendment history. With the summary judgment in this case being entered in our favor, PVA v. Conley becomes the first case in United States history to hold that secretly recording government officials is protected by the First Amendment,” O’Keefe said in a prepared statement.

Meanwhile, the ACLU of Massachusetts sued on behalf of Boston activists René Pérez and Eric Martin.The two activists often record police activity in order to ensure there are no abuses of power. With the help of attorneys from Proskauer Rose, the duo claimed that they could get more accurate recordings if they were made in secret, but that the state’s wiretap law prevented them from doing so.

“We’ve seen that videos of police officers can show the realities of policing in powerful ways: People’s recordings of police interactions have started national conversations about police reform and accountability,” said Carol Rose, executive director of the ACLU of Massachusetts, in a prepared statement. “This ruling reaffirms that the fundamental right to record police officers does not disappear when a recording device is covered.”