The head of the city’s police union asked New Yorkers to pray for a 25-year-old cop who was clinging to life Sunday night after being shot in the head the day before.

Officer Brian Moore, a five-year-veteran, was in critical condition at Jamaica Hospital after undergoing surgery.

His alleged assailant, Demetrius Blackwell, was arrested on charges of attempted murder early Sunday, and ordered held without bail at his arraignment later in the day.

Moore, 25, and his partner, Officer Erik Jansen were on patrol in plain clothes and an unmarked police car when they spotted Blackwell suspiciously adjust something in the waistband of his pants around 6:15 p.m. on Saturday in the area of 212 Street and 104 Avenue, according to Police Commissioner Bill Bratton.

When the officers pulled up behind Blackwell and asked what he was doing, the suspect allegedly pulled out a gun and fired multiple times into the car.

Moore was hit several times in the head, authorities said, and Blackwell fled before the officers were able to return fire. The suspect, who is 35 years old, was apprehended about 90 minutes after the incident.

Jansen was not injured during the melee. Moore, of Long Island, comes from a police family. His father and uncle are retired NYPD sergeants, and Moore has a cousin who is on the force.

“What we ask is that the public, along with the police officers bow their head and pray -- pray not only for Brian, but pray for his family,” Patrolmen’s Benevolent Association President Pat Lynch told NY1 on Sunday. “Just yesterday, they said goodbye to their son, sent him off to work and now they wait in a hospital corridor.”

Blackwell has a criminal history that includes charges of criminal possession of a weapon and robbery. He was arrested early Sunday on charges of first-degree attempted murder, assault and criminal possession of a weapon.

He faces up to life in prison if convicted of the charges, according to Queens DA Richard Brown.

Blackwell was arraigned later Sunday, and appeared in court in a torn jumpsuit, with his hands cuffed and legs shackled, the AP reported. He did not enter a plea, and is due back on May 8.

Moore’s shooting makes him the fifth cop shot since December, when Officers Wenjian Liu and Rafael Ramos were shot and killed while sitting in their police car in Bed-Stuy. Their deaths ignited more than a month of tension between City Hall and the police unions. In early January, two officers were shot in the Bronx while investigating a robbery.