The number of law enforcement officers killed by firearms in the line of duty rose significantly this year, part of an overall increase in the number of officers who died, according to a new report.

There were 50 officers killed in shootings in 2014, a big jump from the 32 such deaths a year earlier, the National Law Enforcement Officers Memorial Fund, a nonprofit organization, said in a report released Tuesday. The number of officers shot and killed this year trails the average number of shootings in each of the last five decades; there were an average of 127 such deaths each year in the 1970s, a number that has fallen each decade, reaching 57 such deaths each year in the 2000s, the report said.

In total, 126 law enforcement officers died this year, up nearly a quarter from the 102 officers who died in 2013, according to the preliminary data in the report. (Last year’s figure was the lowest since World War II, according to the fund.) That annual total is also much lower than it had been for many years. The fund’s records show that between 1966 and 2007, the fatality count dipped below 150 such deaths just three times; since then, including 2014, it has happened in five of the last seven years.

But the report showed some key shifts from last year, pointing out that 15 of the officers “were shot and killed in ambush attacks,” more than any other type of shooting this year and up from five such deaths last year.

The report arrives not long after two New York City police officers were shot and killed while sitting in their police car, an attack that sparked a public rift between Mayor Bill de Blasio and some police officials. Police officers who gathered on Saturday at the funeral of Rafael “Ralph” Ramos, one of the officers killed, expressed frustration at the months of demonstrations against police tactics, with some pointing to the New York shooting as an example of how officers can be targeted.

These demonstrations followed the deaths of Michael Brown in Missouri and Eric Garner in New York, among others, as well as the decisions by grand juries not to indict any of the officers involved. These protests have been very high-profile, resulting in demonstrations across the country since they began erupting into national view over the summer and continuing into the fall and winter. Ismaaiyl Brinsley, identified by authorities as the gunman who shot the two New York officers on Dec. 20, had invoked Brown and Garner’s deaths on social media and vowed to kill police officers; critics of de Blasio, including the head of New York’s largest union, said the mayor had “blood on his hands” and cited the protests as inciting violence against officers.

Yet there were concerns about threats to law enforcement, as well as potential attacks, well before any of these protest movements began. In June, two Las Vegas police officers — Igor Soldo and Alyn Beck — were shot and killed while eating in a CiCi’s Pizza near the Las Vegas Strip. It emerged that the shooters, a husband and wife, viewed law enforcement as the enemy and had talked about killing police officers.

The Las Vegas shooting evoked warnings that authorities had issued in recent years, focused not on people protesting police tactics but on those who view the government as the enemy. The FBI has warned of a growing threat to law enforcement officers, while the Department of Homeland Security warned in 2009 that “domestic extremists” — like a gunman who shot and killed three police officers in Pittsburgh that year — presented a danger. At the time of the Las Vegas shooting, federal authorities said there was not any uptick in threats against law enforcement, but Mark Potok of the Southern Poverty Law Center told The Post that anti-government groups seemed to pose “a rising threat to law enforcement officials.”

The danger is that police officers are a uniformed group who can be easily located and deemed to represent the government, Jim Johnson, police chief of Baltimore County and chairman of the National Law Enforcement Partnership to Prevent Gun Violence. But in general, he said, officers have to be aware of what is happening beyond the neighborhood they police in order to remain safe.

“A safe officer, an officer that is informed, is always aware of what is happening at a local, state and national level, and how these incidents could affect the officer’s safety and his or her ability to do their job,” Johnson told The Post in August, not long after Brown was killed. “You have to be aware of what’s taking place, the pulse of the community, and the community today in our society is greater than just the jurisdiction you work for.”