New York City recorded its fewest number of shooting incidents in 2016 and narrowly missed setting a new record low for homicides since comparable record keeping began more than two decades ago, even as officers make fewer low-level arrests and greatly reduced their use of stop and frisk.

Department officials said they've found the right combination of technology and data collection, police strategies and community engagement.

"This is what 21st century policing looks like, it's data driven, it's smarter, it's more effective," said Chief Dermot Shea, deputy commissioner for operations. "And here's the important part: It works."

According to data released Wednesday, the city had 335 homicides in 2016. The lowest since comparable record keeping for murders began in the 1960s was 333 in 2014. The all-time high was 2,245 in 1990.

Police officials reported 998 shooting incidents in 2016, even as other cities, particularly Chicago, saw double-digit increases. Chicago had 3,550 shooting incidents last year and the city's homicide rate was more than New York and Los Angeles combined. A delegation from Chicago's police department came to the NYPD to learn about its strategies, said Police Commissioner James O'Neill.

"None of this happened by accident," said O'Neill. "It's because of the hard work, the men and women of the NYPD who patrol all of our neighborhoods day in and day out and the communities that support us."

But city officials are still battling the perception both within New York and outside the city that crime is rising, including by President-elect Donald Trump. During a presidential debate Trump claimed that, after the use of stop and frisk was dramatically curbed, "murders are up. All right. You check it."

According to NYPD statistics, while the number of stops has fallen nearly 97 percent since 2011, the number of murders fell since then, too.

Democratic Mayor Bill de Blasio said that curbing the tactic, which had fractured relations between the community and police and which a federal judge said had violated civil rights, has obviously not caused an increase in crime. He said a focus on deepening ties with the community has helped lead to crime decline.

"That's what's working here and this is what is missing in this national debate," he said. "What's a better example than New York City?"