A Fairfax County police officer's badge is covered with a black mourning band for Dallas law enforcement as officers gather July 8 outside of the county courthouse in Virginia. (Christian K. Lee/The Washington Post)

Five police officers were killed and seven others were wounded this week by sniper fire in Dallas, in what has become the deadliest day for the nation's law enforcement officers since 9/11.

Texas has long had a strong gun culture, with the state's gun laws among the country's least restrictive according to the Law Center to Prevent Gun Violence. But late last year, researchers at Harvard and elsewhere discovered an alarming fact: Police officers are much more likely to be killed in the line of duty in states with high rates of gun ownership.

The study, published in the American Journal of Public Health, used FBI data to track police officer deaths in the line of duty from 1996 to 2010. They cross-referenced this with state-level gun ownership rates as measured in a Centers for Disease Control and Prevention survey that asked about gun ownership from 2001 to 2004. To isolate, as accurately as possible, the effects of gun ownership on police officer homicides, they corrected for a number of factors that could also affect police officer homicide rates: overall rates of violent and property crime, the racial and economic demographics of the different states, income, education, alcohol consumption and rural/urban population breakdowns.

They then compared officer fatality rates in the eight states with the lowest public gun ownership rate (13.5 percent, on average) against officer fatalities in the 23 states with the highest gun ownership rate (52 percent, on average). The states with the lowest rates of gun ownership tended to be high-population places such as New York, while the highest rates of gun ownership were in low-population places such as Wyoming. So the researchers compared the 8 "low" states with 23 "high" states to arrive at comparable numbers of law enforcement officers employed in each group over the study period.

The results were shocking: line-of-duty homicide rates among police officers were more than three times higher in states with high gun ownership compared with the low gun ownership states. Between 1996 and 2010, in other words, there were 0.31 officer fatalities for every 10,000 employed officers in low gun ownership states. But there were 0.95 fatalities per 10,000 officers in the high gun ownership states.

"Higher levels of private firearm ownership likely increased the frequency with which officers faced potentially life-threatening situations on the job," the study says. High rates of officer homicides appeared to be caused "by more frequently encountering situations where privately owned firearms were present," it says.

Law enforcement officers "working in states with higher levels of gun ownership faced a greater likelihood of being shot and killed on the job compared with their peers in states with lower gun ownership," the study concludes. The relationship was strong enough that every 10 percent increase in gun ownership correlated with 10 more officer deaths over the study period.

"If we're interested in protecting police officers, we need to look at what's killing them, and what's killing them is guns," said the study's lead author, David Swedler, in a statement last year.

As with all studies, this one has its limitations. Because it only looked at correlations between gun ownership and officer death rates, it can't definitively say whether some other unseen factor may have been driving both.

But the numbers are highly suggestive given the robustness of the findings against all of the potentially confounding factors the researchers did control for. Numbers such as these are one reason many law enforcement groups have been the staunchest supporters of stricter gun control measures.

The International Association of Chiefs of Police, for instance, supports a reinstatement of the federal ban on assault weapons, broadening background checks and creating a national gun offender registry. The Major Cities Chiefs Association, representing police chiefs in the country's largest cities and metro areas, support similar proposals.

By contrast sheriff's groups, which tend to represent law enforcement officers from more rural areas where gun violence is less of a problem, tend to be more skeptical of stricter gun control measures.

The mass shooting attack in Dallas was carried out by one or more assailants armed with what appeared to be assault-style rifles, such as the ones used in seven of the eight other most recent mass shootings in the U.S. These rifles have become very popular among gun enthusiasts in recent years, with the NRA estimating that there are millions in circulation and hundreds of thousands more manufactured each year.

But their increasing use in horrific acts of violence, culminating in the recent shooting of a dozen police officers, underscores the risk these guns pose on officer safety when placed in the wrong hands. And the growing popularity of the weapons suggests that the average beat cop — often armed with only a handgun — may be outgunned by an assailant carrying a military-style rifle designed for use on the battlefield.

More from Wonkblog:

American gun ownership drops to lowest in nearly 40 years

White resentment is fueling opposition to gun control, researchers say

People are getting shot by toddlers on a weekly basis this year