Officials said Moore was shot on a Queens street after he and his patrol partner — in an unmarked police car — pulled up to a man adjusting his waistband in a suspicious way, police Commissioner William Bratton said.

The officers ordered Blackwell to stop and exchanged words with him, but prosecutors say he turned suddenly and fired at least twice, striking Moore. His partner, Officer Erik Jansen, was not hit and radioed for help.

"They did not have an opportunity to get out and return fire," the commissioner said at a news conference Saturday night at Jamaica Hospital Medical Center with Mayor Bill de Blasio and other officials.

After the shooting, witnesses described Blackwell to responding officers and pointed them in the direction he ran, Bratton said. Officers searched house by house and some could be seen walking on roofs as helicopters flew overhead.

Police arrested Blackwell near the crime scene in a house on the block where he lives, officials said.

Blackwell's court-appointed lawyer said after the arraignment that his client was arrested at a house near the shooting site without a warrant and that "the arrest may be illegal."

A police spokesman did not immediately return a call requesting comment about the warrant.

De Blasio said the shooting was a painful reminder of the risks officers take every day.

"Our hearts are with his family, his loved ones," the mayor said. "Our hearts are with his extended family, the men and women of the NYPD."

Moore, who comes from a family of police officers, has been on the job since July 2010.

Moore's listed address is a small, well-kept house in the Long Island hamlet of Massapequa — a tight-knit community where neighbors have known each other well for decades. Many families have relatives who are police officers.

Neighbors had only kind words for Moore, some saying they shed tears after hearing he was shot.

The attack instantly evoked fears of the December slayings of two uniformed officers, Wenjian Liu and Rafael Ramos, as they sat in their patrol cars in Brooklyn. The shooter had posted online that he was seeking retribution against officers for the death of Eric Garner in an apparent chokehold by police.

Bratton said Blackwell has a criminal record that includes a weapons possession charge, but the suspect made no such anti-police postings and was being pursued by the anti-crime officers because of his behavior.

Neighbors near the scene of the shooting were surprised by the shooting and described the residential area with many two- and three-family homes as quiet and safe.