This photo provided by the New York Police Department shows officer Rafael Ramos. Ramos and officer Wenjian Liu where shot and killed Saturday, Dec. 20, 2014, in the Brooklyn borough of New York. The suspect, 28-year-old Ismaaiyl Brinsley, ran to a subway station and killed himself.

This photo provided by the New York Police Department shows officer Wenjian Liu. Liu and officer Rafael Ramos where shot and killed Saturday, Dec. 20, 2014, in the Brooklyn borough of New York. The suspect, 28-year-old Ismaaiyl Brinsley, ran to a subway station and killed himself.

Mourners stand at attention as the bodies of two fallen NYPD police officers are transported from Woodhull Medical Center, Saturday, Dec. 20, 2014, in New York. An armed man walked up to two New York Police Department officers sitting inside a patrol car and opened fire Saturday afternoon, killing one and critically wounding a second before running into a nearby subway station and committing suicide, police said.

NEW YORK — A gunman who said online that he planned to shoot two “pigs” in retaliation for the police chokehold death of Eric Garner ambushed two officers in a patrol car and shot them to death in broad daylight Saturday before running to a subway station and killing himself, authorities said.

The suspect, 28-year-old Ismaaiyl Brinsley, wrote on an Instagram account: “I’m putting wings on pigs today. They take 1 of ours, let’s take 2 of theirs,” officials said. He used the hashtags Shootthepolice RIPErivGardner (sic) RIPMikeBrown.

Police said he approached the passenger window of a marked police car and opened fire, striking Officers Rafael Ramos and Wenjian Liu in the head. The officers were on special patrol doing crime reduction work in the Bedford-Stuyvesant section of Brooklyn.

“They were, quite simply, assassinated — targeted for their uniform,” said Police Commissioner William Bratton, who looked shaken at a hospital news conference.

Brinsley took off running as officers pursued him to a nearby subway station, where he shot himself in the head. A silver handgun was recovered at the scene, Bratton said.

“This may be my final post,” he wrote in the Instagram post that included an image of a silver handgun. The post had more than 200 likes.

Bratton confirmed that Brinsley made serious “anti-police” statements online but did not get into specifics of the posts.

He said they were trying to figure out why he had chosen to kill the officers. Two city officials with knowledge of the case confirmed the posts to The Associated Press. The officials, a senior city official and a law enforcement official, were not authorized to speak publicly on the topic and spoke on condition of anonymity.

The Rev. Al Sharpton said Garner’s family had no connection to the suspect and denounced the violence.

“Any use of the names of Eric Garner and Michael Brown in connection with any violence or killing of police is reprehensible and against the pursuit of justice in both cases,” Sharpton said.

Brown’s family also released a statement condemning the shooting.

“We must work together to bring peace to our communities,” the statement says. “Our thoughts and prayers go out to the officers’ families during this incredibly difficult time.”

Police in New York are being criticized for their tactics after the July death of Garner, who was stopped on suspicion of selling loose, untaxed cigarettes. Amateur video showed an officer wrapping his arm around Garner’s neck and wrestling him to the ground. Garner was heard gasping “I can’t breathe” before he lost consciousness and later died.

Demonstrators around the country have staged die-ins and other protests since a grand jury decided Dec. 3 not to indict the officer in Garner’s death, a decision that closely followed a Missouri grand jury’s refusal to indict a white officer in the fatal shooting of Brown, an unarmed black 18-year-old. Bratton said they were investigating whether the suspect had attended any rallies or demonstrations.

Brinsley was black. The officers were Asian and Latino, police said.

Mayor Bill de Blasio said the killing of the officers strikes at the heart of the city.

“Our city is in mourning. Our hearts are heavy,” said de Blasio, who spoke softly with moist eyes. “It is an attack on all of us.”

Scores of officers in uniform lined up three rows deep outside the hospital to honor the fallen police officers. The mayor ordered flags at half-staff.

In a statement Saturday night, Attorney General Eric Holder condemned the shooting deaths as senseless and “an unspeakable act of barbarism.” President Barack Obama was briefed on the shooting, and White House officials were monitoring the situation closely, the White House said.

Early Saturday, Bratton said, Brinsley went to the home of a former girlfriend in the Baltimore area and shot and wounded her. Police there said they noticed Brinsley posting to the woman’s Instagram account about a threat to New York officers. Baltimore-area officials sent a warning to New York City police, who received it around the time of the shooting, Bratton said.

Criminal records show Brinsley has a history of arrests on various charges in Georgia, including robbery, shoplifting, carrying a concealed weapon, disorderly conduct and obstruction of a law enforcement officer. Bratton said his last-known address was Georgia.

Ramos was married with a 13-year-old son, police said. He had been on the job since 2012. Liu had been on the job for seven years and got married two months ago, Bratton said.

The president of the police officers union, Patrick Lynch, and de Blasio have been locked in a public battle over treatment of officers after the grand jury decision in the Garner case.

On Saturday, some officers turned their backs on de Blasio as he walked into the hospital. At a news conference, Lynch said there is “blood on many hands tonight,” explicitly blaming the mayor and protesters.

More in News

Using data from the Dartmouth Atlas – a source of information and analytics that organizes Medicare data by a variety of indicators linked to medical resource use – we recently ranked geographic areas based on markers of end-of-life care quality, including deaths in the hospital and number of physicians seen in the last year of life.

Wednesday morning two independent research teams, one based in the Netherlands and the other in California, reported that the deluge from Hurricane Harvey was significantly heavier than it would have been before the era of human-caused global warming.

Denver’s newest skyscraper will be home to one of the city’s most recognizable home-grown business by the end of next year. Chipotle is moving its 450 downtown corporate staff into the 1144 Fifteenth tower by the end of 2018.