A federal judge last week threw out an Oklahoma law allowing employees to keep guns in parked cars on company property, saying the legislation conflicted with workplace safety  regulations.

In his decision, U.S. District Court Judge Terence Kern said federal law requires employers to "abate hazards in their workplaces that could lead to death or serious bodily harm." That includes preventing gun-related workplace injuries, Kern said.

The ruling follows a legal battle led by energy firm Conoco Phillips and other companies, which sought an injunction against the 2004 state law on the grounds that it violated employers' private property rights, among other issues.

In response to the lawsuit, the National Rifle Association called for a boycott of Conoco Phillips gas stations, arguing that business owners have no right to regulate the "lawful contents of a person's privately-owned automobile." It also rallied other states to approve similar laws, which have since passed in Alaska, Minnesota, Kentucky, and Kansas.

The Oklahoma law, which was approved unanimously as a series of amendments by House lawmakers, prevented employers from implementing any workplace policy that barred firearms in "locked vehicles on any property set aside for any vehicle."

Kern said that conflicted directly with the federal Occupation Safety and Health Act, which requires employers to minimize workplace risks.

"The judge made the right decision in this case," Paul Helmke, president of the Brady Center to Prevent Gun Violence, said in a statement. "The safety of American workplaces should take precedence over allowing individuals to rapidly arm themselves with dangerous weapons."

Last year, 516 people were killed in workplace homicides in the United States, according to the Bureau of Labor Statistics. Despite a 50 percent decline since the mid-1990s, homicide remains the fourth most frequent cause of death in U.S. workplaces, behind highway accidents, falls, and falling objects.