SAN FRANCISCO — In a surprising ruling, a federal appeals court Thursday declared unconstitutional the restrictions that many California counties have used to sharply limit the right to carry a concealed handgun.

The 2-1 ruling by the 9th U.S. Circuit Court of Appeals in a San Diego case isn’t final because it could still be appealed. But if it stands, “California will join the vast majority of other states that now (freely) issue permits to people for self-defense,” said Chuck Michel, attorney for the California Rifle and Pistol Association.

That would be a sea change for most Bay Area counties, where sheriffs generally require applicants to show evidence that their safety is at such great risk that it can only be addressed by giving them a permit to carry a gun. But in other parts of the Golden State, it’s much easier to get a concealed-carry permit: While sheriffs in urban counties hand out permits by the dozens, sheriffs in less-populated rural continues hand them out by the thousands.

Thursday’s ruling, cheered by pro-gun groups and panned by gun-control advocates, means that one day all law-abiding Californians with the right training and a desire for self-defense could have the right to carry concealed handguns.

San Diego still can seek review of the ruling by an 11-judge panel of the 9th Circuit. If that is denied, or if either side chooses to appeal the larger panel’s ruling, the case could go to the U.S. Supreme Court.

By state law, requirements for concealed-carry permits include demonstrating “good moral character,” taking a training course and establishing “good cause.”

It’s up to counties and cities to set policies for seeking such permits, and this lawsuit — filed by several San Diego residents and Michel’s organization — challenged San Diego’s interpretation of “good cause.”

The county’s policy requires “a set of circumstances that distinguish the applicant from the mainstream and causes him or her to be placed in harm’s way.” But concern for “one’s personal safety alone is not considered good cause,” San Diego’s policy says. Applicants have had to provide documentation — such as restraining orders, letters from law enforcement or prosecutors — to prove a special need for self-protection.

A federal district judge had ruled that’s OK in order to protect public safety, but the 9th Circuit reversed that ruling Thursday, finding the county’s policy “impermissibly infringes on the Second Amendment right to bear arms in lawful self-defense.”

Among those lauding Thursday’s ruling was Tom Scocca of San Jose, who sought a concealed-carry permit in 2008 but was turned down by Santa Clara County Sheriff Laurie Smith after he could not show “good cause.”

The former law enforcement officer, who now heads up global security at a major Silicon Valley tech company, sued Smith, saying her denial was unconstitutional especially when others with similar backgrounds in the county had received permits. His case had been put on hold pending the 9th Circuit’s ruling in the San Diego case and a similar one in Yolo County.

Scocca said Thursday’s ruling had him “checking the calendar to see if it was April Fool’s Day,” because “no one really expected an opinion of that type out of the 9th Circuit.” He said he’s guardedly optimistic that the decision will stick even if appealed.

Most Bay Area counties have policies like San Diego’s. Alameda County, for example, requires an applicant to show “a documented, presently existing, clear and present danger to life or great bodily harm” specific to the applicant or that person’s immediate family. The applicant also must show that police or other measures can’t adequately address that danger and that issuing a permit is likely to significantly reduce the danger.

Gun-control groups said Thursday they hoped the decision by two conservative judges would be dismissed by the larger 9th Circuit panel.

No history or precedent supports “this aberrant, split decision that concocts a dangerous right of people to carry hidden handguns in public places” for those whom law enforcement finds lack good cause to do so, said Jonathan Lowy, director of the Brady Center to Prevent Gun Violence’s Legal Action Project. “The parents of Jordan Davis and Trayvon Martin, whose children were killed by licensed concealed-carry holders, could educate the court about the real dangers posed by this legal error.”

The case may be ripe for the Supreme Court’s review since three other circuits on the East Coast have ruled differently, setting up a conflict. The Supreme Court ruled in 2008 that law-abiding citizens can keep handguns in the home for self-defense but didn’t determine whether that right extends outside the home.

Circuit Judge Diarmuid O’Scannlain wrote Thursday’s opinion and Consuelo Callahan concurred, while Judge Sidney Thomas penned a scathing dissent, writing that San Diego’s policy falls squarely within what the Supreme Court has called “presumptively lawful regulatory measures.”

“In dealing a needless, sweeping judicial blow to the public safety discretion invested in local law enforcement officers and to California’s carefully constructed firearm regulatory scheme, the majority opinion conflicts with Supreme Court authority, the decisions of our sister circuits and our own circuit precedent,” Thomas wrote.

Staff writer Tracy Seipel contributed to this report. Contact Josh Richman at 510-208-6428. Follow him at Twitter.com/josh_richman. Read the Political Blotter at IBAbuzz.com/politics.