The cops were inside a home at 145-86 179th St. in Queens shortly after 12:45 p.m. when they encountered Rondell Goppy, who opened fire, police said.
Officer Christopher Wells, 36, was shot in the leg and suffered a broken femur. Officer Joseph Murphy, 32, was wounded in the hand. Both officers' injuries required surgery. Wells has been on the force for 14 years and Murphy for six.
They were listed as stable, police Commissioner Dermot Shea said.
Goppy, 41, a peace officer at the City University of New York in Harlem, was shot in a gunfire exchange and pronounced dead at the scene.
Hours earlier, a 41-year-old woman, believed to be Goppy's wife, went to the NYPD's 105 Precinct to report a domestic incident from Monday night, Shea said. The two officers went back to the home with her, and were there for six minutes when Goppy arrived.
"Almost instantly, he walks in the front door and starts shooting at our two officers, " Shea said.
The officers returned fire. It was not clear how many times Goppy was hit. The woman was not injured. Investigators recovered two handguns at the scene and another somewhere else, Shea said. Goppy was licensed to carry firearms.
Shea said Goppy did not have a criminal record, but officers previously had responded to the residence for domestic issues. He said investigators were looking into what happened in those cases.
Mayor Bill de Blasio said he met with the families of the injured officers.
"Here you have officers who do the Lord's work," he said. "They protect survivors of domestic violence. They go into some of the most volatile, difficult situations that you could possibly imagine."
Pat Lynch, the president of the Police Benevolent Association, the city's largest police union, blasted elected officials about slashed police budgets.
"Sometimes in a college classroom ... in a council room ... on a Zoom conference talking about policing, it seems awfully easy to say, 'Here's the script and here's what we'll do,'" he said. "What we see here today ... there is no script. We can't be removed."
The shooting occurred after a brief 24-hour respite from gun violence in the city. The New York Post reported that 1,704 people have been shot this year as of Monday.