The man who killed two New York police officers, identified as Ismaaiyl Brinsley, told members of the public “watch what I’m going to do” shortly before the attack, police have said.
The 28-year-old man had a history of violence and mental instability.
Candlelit vigils have been held in New York in memory of the two officers, Liu Wenjin and Raphael Ramos.
Brinsley shot them as they sat in their patrol car in Brooklyn before he ran into a nearby subway station where he reportedly shot himself.
Earlier, before the shooting, he had posted messages on social media saying he would kill police officers in retaliation for the death of Eric Garner, a black man who died when white police officers arrested him.
The Rev Al Sharpton, a prominent civil rights activist, said Mr Garner’s family had no connection to the gunman and called the killings “reprehensible”.
Community leaders have called for peace and the mayor of New York, Bill de Blasio, has ordered flags across the city to be flown at half-mast.
Brinsley, 28, had been arrested at least 19 times and had a troubled childhood so violent that his mother was afraid of him, police said.
In online postings, he expressed “self-despair and anger at himself and where his life was”, Chief of Detectives Robert Boyce said.
Before the shootings, Brinsley shot and wounded a former girlfriend.