A gunman in New York has shot dead two police officers and then himself apparently in retaliation for the deaths of black men, Michael Brown and Eric Garner.

28-year-old Ismaaiyl Brinsley shot officers Liu Wenjin and Rafael Ramos while they were sitting inside a patrol car and then killed himself inside a subway station.

According to the head of the New York police, Brinsley targeted the officers for their uniform. He had also earlier shot and injured his ex-girlfriend and had posted anti-police messages on social media.

The gunman had announced his plans to harm police officers via Instagram saying:

“I'm Putting Wings On Pigs Today. They Take 1 Of Ours... Let's Take 2 of Theirs #ShootThePolice #RIPErivGardner  #RIPMikeBrown. This May Be My Final Post. I'm Putting Pigs In A Blanket.”

He also posted a photo of a silver handgun and another of himself in bloodstained clothes.