Hundreds of Massachusetts police commemorated officers killed in the line of duty Wednesday, amid a year marred by violence between police and the communities they protect.

“Everyone here today knows that it’s been a challenging year throughout our country. Far too many of our fellow officers have made that ultimate sacrifice,” Boston Police Det. Cecil Jones, the president of the Massachusetts Law Enforcement Memorial Foundation, said at the annual gathering.

A shooter in Dallas, Texas reportedly targeted and killed five police officers during a protest there in July. Another July incident in Baton Rouge, Louisiana claimed the lives of three officers and injured another three when a gunman attacked outside a convenience store.

Support for GBH is provided by:

“It is a scary time to be in law enforcement, especially for those who are on the front lines every day,” Attorney General Maura Healey said.

Healey said she wanted to use the event to “recognize the officers who’ve lost their lives, who’ve been specifically targeted in places like Dallas ... and in Baton Rouge.”

According to a report by the National Law Enforcement Officers Memorial Fund, 41 police officers have been killed in firearms related incidents this year, up from just 28 in 2015, a 46 percent increase.

“Shot and killed in the line of duty,” Healey said of the statistic. “That’s a remarkable figure.”

The same organization reports that officer deaths in general are down over the last decade. The report lists 123 officer deaths in 2015 with 145.6 deaths the average annual number between 2005 and 2015.

Tensions have risen in neighboring Somerville this summer, where that city’s police union called a Black Lives Matter banner disrespectful to police and demanded it be removed from the front of City Hall. Mayor Joseph Curtatone refused to remove the banner.

Support for GBH is provided by:

“I will continue, as my fellow officers do every day across this nation, regardless of those who attack the law enforcement community for their own personal gains, to remain dedicated to working in partnership with our communities to fight crime, reduce fear, improve the quality of life in the neighborhoods and I will never forget the sacrifice that the families here have made,” Jones said in his remarks.

Speaking after the event, Boston Police Commissioner Bill Evans said the acts of violence against police and the growing protest movement against authorities’ use of force are not altering the way BPD does business.

“It’s unfortunate what’s playing out in other parts of the country and we hope it doesn’t spill over here, but I’m very proud of the community work our officers do and I feel that when I’m out in the community,” Evans said.

The memorial group held its 29th annual “Reading of the Roll” ceremony Wednesday outside the State House. The gathering honors local, state and federal officers who have been killed in the line of duty and included new three new additions to the memorial: Lynn officer George Crowell, who was beaten to death in 1875, Peabody officer Edward Scott Johansen, who died from hepatitis in 1977 after contracting the disease while performing CPR, Boston officer Jose Maceira, who died from complications from a gunshot wound in 1977 and Saugus officer Phillip Pitts, who was killed in 1889 during a robbery.

Auburn officer Ronald Tarentino, who was shot during a traffic stop, and State Trooper Thomas Clardy, who was the victim of a car crash on the Mass. Pike, will be added to the memorial in 2017.