A man who served five years in prison for attempted murder was arraigned Sunday on charges that he shot a New York City police officer in the head.

Demetrius Blackwell was ordered held without bail after appearing in court in a torn jumpsuit with his hands cuffed behind his back and legs shackled.

He was arrested Saturday night and charged with attempted murder in the shooting of Officer Brian Moore, who remained hospitalized in critical but stable condition after hours of surgery. Doctors have placed him in a medically induced coma.

At the arraignment, the 35-year-old suspect did not enter a plea. He is due back in court Friday.

Officials said Moore was shot on a Queens street after he and his patrol partner — both in plainclothes 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 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 declined to comment on the warrant, citing the ongoing investigation.

According to state corrections records, Blackwell was convicted in 2001 on an attempted murder charge. Details on the case were not immediately available, but records show he pointed a handgun at someone and demanded property, then fired shots at a car.

He served the full five years of his sentence, and then returned to prison for violating parole in 2007. He was rereleased in 2008.

According to the New York Post, Blackwell has a record of 10 arrests, including five on charges of robbery, criminal possession of a weapon and grand larceny.

De Blasio said Saturday's 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 has been on the job since July 2010, comes from a family of police officers. His father and uncle are retired NYPD sergeants, and his cousin is a city cop, the New York Post reported.

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.

"He's a good kid," an unidentified woman told the New York Post. "We're all praying for him. I've known him since he was a baby."

The attack 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.

If convicted, Blackwell faces up to 25 years to life in prison.

The Associated Press contributed to this report