New York gunman Ismaiiyl Brinsley said 'watch what I'm going to do' before killing police officers

Ismaiiyl Brinsley warned the public about 'what he was going to do'(Reuters)

The gunman who shot dead two New York police officers warned the public "watch what I'm going to do", before he executed two NYPD officers in their squad car.

Lui Wenjin, 32, and Raphael Ramos, 40, were ambushed in Brooklyn by Ismaiiyl Brinsley, 28, in what the NYPD has described a targeted assassination.

Brinsley, who had a long history of mental instability and hatred towards police, posted a warning on social media threatening to shoot two "pigs" in a revenge attack for the deaths of Michael Brown and Eric Garner.

Police said Brinsley had been arrested at least 19 times and had a troubled childhood, and was so violent that his mother was afraid of him.

Candlelit vigils have since been held in Central Park, New York City, in memory of the two officers.

A woman holds a candle as demonstrators gather in Central Park in Harlem, New York City, for a candlelight vigil and march for justice December 21, 2014(Reuters)

Lucy Ramos, an aunt of police officer Raphael, during one of the memorials, said she hoped "we can move forward and find an amicable path to a peaceful coexistence".

Bill de Blasio, the New York mayor, ordered flags to be flown at half-mast across the city.

Many officers turned their backs on de Blasio at a news conference following his recent support for protests against police.

Hundreds took to social media saying he had "blood on his hands" and should "be charged with murder".

Garner and Brown, both of African-American ethnicity, died at the hands of white police officers in separate incidents in New York and Missouri, sparking widespread protests and violence across the United States.

The Rev Al Sharpton, said Garner's family had no connection to the gunman and described the New York killings as "reprehensible".

Brown's family also condemned the shooting of the New York City officers.

The statement released by Parks & Crump law firm said Brown's family rejected "any kind of violence directed toward members of law enforcement. It cannot be tolerated".