A social media war erupted between doctors and the National Rifle Association Thursday, just as 12 people were shot and killed at a California nightclub and hours before the Centers for Disease Control and Prevention released new figures showing gun deaths on the rise across the country.

Doctors and medical officials have increasingly taken on gun violence as a public health issue. Last month, the American College of Physicians issued new guidelines for doctors to follow in helping protect patients from firearms dangers, and published several reports on gun violence in its flagship publication, the Annals of Internal Medicine.

“We need to ask our patients about firearms, counsel them on safe firearm behaviors, and take further action when an imminent hazard is present,” Dr. Garen Wintemute, of the Violence Prevention Research Program at the University of California Davis Medical Center, wrote in one editorial in the magazine.

On Wednesday, the NRA took issue with the ACP, which represents more than 150,000 internal medicine specialists. “Someone should tell self-important anti-gun doctors to stay in their lane,” the group tweeted.

Doctors across Twitter piled back on.

“We are not anti-gun; we are anti-bullet holes in our patients,” retorted emergency medicine specialist Dr. Esther Choo of Oregon Health & Science University in a tweet Thursday morning.

Dr. Joseph Sakran, director of emergency general surgery at Johns Hopkins Medicine, tweeted his dismay over the gun advocacy group's “divisive statement.”

“We take care of these patients every day. Where are you when I’m having to tell all those families their loved one has died?," he wrote.

And the Annals of Internal Medicine, the influential journal for the ACP, tweeted a pledge to its 33,000 followers to talk to at-risk patients about gun violence.

Doctors have increasingly fought for more freedom to research gun violence and deaths and to speak to patients about the risks. In Florida, lawmakers sought to prevent doctors from asking about guns in the home but in 2017 a federal appeals court ruled against the law.

And Congress had quietly limited CDC research into firearms violence using carefully worded legislation and budget cuts that precisely matched the CDC’s budget for such research.

Former President Barack Obama directed the CDC to resume gun research.

RISE IN VIOLENT CRIMES, SUICIDE

The CDC published new data on Thursday showing that gun deaths rose in 2015-16 after having started to fall in earlier years. The report says the rise in deaths is driven by both violent crime and by suicides.

“During 2015–2016, homicide was the 16th leading cause of death among persons of all ages in the United States and the third leading cause among youths aged 10–19 years; a firearm injury was the underlying cause of death in 74 percent of all homi­cides and in 87 percent of youth homicides,” the CDC team said in the new report.

More than 27,000 people were killed by guns in 2015-16 and nearly 45,000 people died by suicide using a firearm, the CDC said.

“Previously observed decreases in firearm homicide rates have not continued, with more recent rates showing an increase both nationally and in large (urban areas),” the CDC team wrote.

“It is too soon to know whether recent increases in fire­arm homicide rates represent a short-term fluctuation or the beginning of a longer-term trend,” the team added.

“From 2015 to 2016, violent crime increased 3.8 percent for the nation overall, 6.1 percent in cities with populations of 250,000 and higher, 2.2 percent in suburban areas and 1.6 percent in nonmetropolitan counties.”

Access to guns is one clear factor, the CDC said. Research shows the decision to die by suicide is often a last-minute thought.

“Reducing access to lethal means during an acute suicidal crisis by safely storing firearms or temporarily removing them from the home can help reduce suicide risk, particularly among youths,” the team wrote.

“Efforts to strengthen household financial security; stabilize housing; teach youths coping and problem-solving skills; identify and support persons at risk; and imple­ment proactive prevention policies in schools, workplaces, and other organizational settings are associated with reductions in suicide,” the CDC team added.

Careful policing can help reduce homicides, the CDC team said. So can community efforts such as business improvement districts, housing tax credits and cleaning up abandoned buildings and lots. Restraining orders against people with a history of domestic violence can prevent homicides, as can background checks for gun buyers.