A gunman shot dead two New York City police officers in what officials called an “assassination”, hours after warning on social media that he planned an attack in retribution for recent US police killings of unarmed black men.

Mayor Bill de Blasio yesterday ordered flags flown at half staff around the city. New York City’s main police union harshly criticised the city’s first Democratic mayor in two decades for being insufficiently supportive of the department during recent waves of anti-police violence.

The gunman, 28-year-old Ismaaiyl Abdula Brinsley, travelled from Baltimore, where police said he had shot and wounded his girlfriend, to New York and during the day posted on the social media service Instagram that he would be “putting wings on pigs today,” using an anti-police slur.

They take one of ours, let’s take two of theirs

The two New York City Police Department officers, Rafael Ramos, 40, and Wenjian Liu, 32, had no time to react when Brinsley appeared next to their vehicle, and shot both officers with a silver semi-automatic handgun, said NYPD Police Commissioner William Bratton.

Baltimore police said they learned of the suspect’s posts on Saturday afternoon and called NYPD officials to alert them that digital data showed he had traveled to the city’s borough of Brooklyn. But the call came in less than an hour before officials said Brinsley, who was black, shot and killed two officers as they sat in their patrol car near a major housing project.

The officers he killed were Hispanic and Asian-American.

Brinsley fled to a nearby subway station where he shot himself in the head and died, Bratton added.

The attack, the first fatal shooting of an NYPD officer since 2011, follows weeks of sometimes violent protests around the United States over a pair of incidents in which white police officers shot and killed unarmed black men. In July, a police officer in New York’s Staten Island borough killed Eric Garner, a father of six, while trying to arrest him for illegally selling cigarettes.

In each case, grand juries that reviewed the deaths concluded that the police officers involved had broken no laws. The decisions not to charge the officers added to protesters’ anger.

De Blasio, who called the attack an “assassination,” and Bratton attended a Sunday morning service at St Patrick’s Cathedral, where Cardinal Timothy Dolan addressed the shooting.

“We mourn the brutal and irrational execution of two young, promising, devoted police officers,” Dolan said. “We worry about a city tempted to tension and division.”

In August, a police officer in the St Louis suburb of Ferguson, Missouri, shot and killed a 18-year-old Michael Brown after an argument that began while Brown was walking in the middle of the street on a residential block after allegedly stealing a box of cigarillos from a convenience store.

Brinsley cited both cases in the Instagram post in which he threatened police, saying “they take one of ours ... let’s take two of theirs.”

Meanwhile, 30 miles northwest of Tampa, Florida, a police officer was shot and killed early yesterday, local authorities reported. They did not release a motive for the attack.

Leaders of recent anti-police protests, including longtime New York civil rights activist Reverend Al Sharpton, also condemned the attack.

Bratton said investigators were checking whether Brinsley had attended any of the recent protests.

Sign up to our free newsletters

Get the best updates straight to your inbox:
Please select at least one mailing list.

You can unsubscribe at any time by clicking the link in the footer of our emails. We use Mailchimp as our marketing platform. By subscribing, you acknowledge that your information will be transferred to Mailchimp for processing.