A gunman who announced online that he was planning 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 New York Police Department 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 Bill Bratton, who looked pale and shaken at a hospital news conference.

Brinsley took off running as officers pursued him down 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," Brinsley wrote in the Instagram post that included an image of a silver handgun. The post had more than 200 likes.

Bratton confirmed that the suspect made very serious "anti-police" statements online but did not get into specifics of the posts. He said they were trying to figure out why Brinsley had chosen to kill the officers. Two city officials with direct 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.

Tense time

The shootings come at a tense time; Police in New York and nationwide are being criticized for their tactics, following the July death of Garner, who was stopped on suspicion of selling loose, untaxed cigarettes. Amateur video captured 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 Hispanic, police said.

USA-NEWYORK/POLICE

Police Commissioner William Bratton said the suspect had shot his former girlfriend earlier Saturday in Baltimore. (Stephanie Keith/Reuters)

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."

Mayor Bill de Blasio said the killing of the officers in the nation's largest department 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."

Silent salute

Scores of officers in uniform lined up three rows deep lined the hospital driveway and stretched into the street, their hands raised in a silent salute, as two ambulances bore the slain officers' bodies away. 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, in a statement issued while he's vacationing in Hawaii, said he unconditionally condemns the slayings.
 
"The officers who serve and protect our communities risk their own safety for ours every single day -- and they deserve our respect and gratitude every single day," Obama said. "Tonight, I ask people to reject violence and words that harm, and turn to words that heal — prayer, patient dialogue, and sympathy for the friends and family of the fallen."

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, but he had some ties in Brooklyn.