A federal judge found the D.C. government liable Wednesday for wrongfully arresting between 2012 and 2014 six people who were accused of violating its ban on carrying handguns in public.

U.S. District Judge Royce C. Lamberth did not rule on a motion seeking class-action status, but the decision, if upheld, could clear the way for claims for damages by as many as 4,500 people similarly arrested under the law the courts overturned in 2014, according to court filings.

The decision is the latest in a long line of litigation after Washington’s strictest-in-the-nation gun regulations made the nation’s capital a key focus for gun rights activists two decades ago. The Supreme Court struck down the District’s long-standing ban on handguns in a landmark 2008 ruling in District of Columbia v. Heller, which found that the Second Amendment protected individuals’ right to own a gun in the home.

The District enacted new restrictions on openly carrying firearms in the city, but a federal judge in July 2014 and an appeals court in July 2017 again struck down regulations requiring residents to show “proper reason” to do so, such as a fear of injury or transporting valuables. The 2014 ruling also barred the city from enforcing carrying restrictions against people “based solely on the fact that they are nonresidents.”

The city subsequently repealed statutes criminalizing possession of firearms not registered in D.C., possession of ammunition by people without a D.C.-registered firearm and otherwise barring possession by nonresidents.

In Wednesday’s 19-page opinion, Lamberth rejected the D.C. government’s defense that it could not have violated the plaintiffs rights before a court struck down its statutes.

Instead, Lamberth ruled, laws banning carrying firearms in public and nonresidents from registering firearms, and permitting the arrest of nonresidents for carrying weapons or ammunition without a license, “go the core of the Second Amendment.” The judge said the amendment preserves the “right of responsible citizens to carry firearms for personal self-defense beyond the home, subject to long-standing restrictions,” quoting the 2017 opinion, Wrenn v. District of Columbia.

“The District violated the plaintiffs’ Second Amendment rights by arresting them, detaining them, prosecuting them, and seizing their guns based on an unconstitutional set of D.C. laws,” Lamberth wrote.

The judge upheld a challenged D.C. provision in which it returns firearms seized from arrested individuals to their home states to retrieve.

William “Chas” Claiborne, an attorney for the six plaintiffs — two District residents and four nonresidents — said in an interview that they “are very happy with the ruling, which completely vindicates their claim that they had a constitutional right to carry their handguns in public for self-defense.”

D.C. officials attributed about 4,500 arrests and 1,900 prosecutions to the statutes in court filings. Nearly all were jailed at least overnight, although charges were eventually dropped against most. About half the arrests involved nonresidents, and a third involved people not accused of committing other crimes, such as possessing a firearm after being convicted of a felony, plaintiffs said.

A spokesman for the office of D.C. Attorney General Karl A. Racine (D) said it is still reviewing the ruling and had no comment at this time.

Before retreating under adverse court rulings, D.C. officials defended the restrictions as reasonable and necessary in a city that struggles with gun violence and faces heightened security challenges because of a concentration of federal government buildings and diplomats.

Case law allows for people to claim damages for wrongful arrest, jailing and prosecution as a group, or if class certification is denied, to file individual suits.

The D.C. government this year, for example, agreed to pay $1.6 million to settle two lawsuits alleging that police unlawfully detained more than 200 people in mass arrests the day of President Donald Trump’s inauguration in January 2017. The settlement awarded $605,000 to six defendants and nearly $1 million to about 200 others falsely arrested and held up to 16 hours.

The plaintiffs in the case decided Wednesday included lead member Maggie Smith, a North Carolina nurse with no prior criminal record who was arrested after telling D.C. police during a routine traffic stop that she was carrying a pistol licensed in her home state, three men from Virginia and Maryland, and two District residents. Each was arrested between July 2012 and June 2014, and had cases dropped in 2014 or 2015.