Doctors in Florida can legally counsel patients about gun risks under a federal appeals court ruling that strikes down the state’s controversial “Docs vs. Glocks” gun law.

The 11th Circuit Court of Appeals in Atlanta ruled Thursday that Florida’s National Rifle Association-backed law violated doctors’ First Amendment rights.

Read the full ruling below.

The Firearm Owners’ Privacy Act, signed in 2011 by Gov. Rick Scott (R), broadly prohibited doctors, emergency room workers and other health care professionals from asking patients whether they had guns, except in vaguely defined circumstances “relevant to the patient’s medical care or safety.”

The law said doctors “should refrain from unnecessarily harassing a patient about firearm ownership during an examination” and prohibited discrimination against firearms owners by refusing care or counseling against firearm ownership. Violators faced huge fines and revocation of their medical license.

The law was immediately challenged by the Brady Center to Prevent Gun Violence, which sued the state on behalf of several doctors and more than 11,000 health care organizations.

Doctors routinely ask patients about potential hazards in the home, including drugs, chemicals, firearms and swimming pools. The American Medical Association for nearly 30 years has encouraged members to ask about guns in particular “as a part of childproofing the home and to educate patients to the dangers of firearms to children.”

The NRA and other gun advocates cited six anecdotes of patients who complained questions about firearms ownership invaded their privacy. In one instance, a pediatrician advised a mother who wouldn’t reveal whether she kept a gun in her home to find another doctor.

Florida’s gun laws are weaker than all but a handful of other states, according to rankings by the non-profit group Law Center to Prevent Gun Violence.

Jonathan Lowy, co-counsel in the case and director of the Brady Center to Prevent Gun Violence, praised the court’s decision.

“Today’s ruling is an important victory for public safety and free speech rights, and a crushing defeat for the corporate gun lobby and the politicians who do its bidding,” Lowy said in a statement. “Politicians and special interest lobbies have no business standing between doctors and their patients, or keeping doctors from telling people the truth about the risks of guns or other products.”

The ruling can be appealed to the U.S. Supreme Court.