Moments before opening fire, Ismaaiyl Brinsley approached people in the street in Brooklyn and asked them to follow him on Instagram, then told them “Watch what I’m going to do”, chief of detectives Robert Boyce said.
The portrait of the Brooklyn-born gunman emerged as big-city police forces and union leaders around the US warned officers to change their routines and insist on extra back-up a day after Brinsley carried out what he portrayed online as retaliation for the killings of black men by white police officers.
Brinsley was black and the murdered officers were Asian and Hispanic.
The killings come at a tense time when police nationwide have been criticised for months for their tactics following Eric Garner’s death after being put in a chokehold by a New York officer and the fatal shooting of Michael Brown, 18, in Ferguson, Missouri.
Protests have erupted in recent weeks after grand juries declined to charge the white officers involved.
Investigators were trying to determine if Brinsley, who killed himself after the murders, had taken part in any protests over the deaths of Mr Brown and Mr Garner, whose names he invoked in his online threat, or simply latched on to the cause for the final act in a violent rampage.
They said he travelled frequently between America’s South and New York, where he fathered a child in Brooklyn, and had been in the city earlier in the week.
Brinsley, 28, had been arrested at least 19 times in Georgia and Ohio, spent two years in prison for gun possession and had a troubled childhood so violent that his mother was afraid of him, police said.
He ranted online about police and the government and expressed “self-despair and anger at himself and where his life was,” Mr Boyce said.
The police chief said Brinsley’s mother believed he had undiagnosed mental problems and may have been on medication at some point, but detectives were still trying to determine if he had a mental illness.
On Saturday afternoon Brinsley approached a squad car from behind in Brooklyn’s Bedford-Stuyvesant neighbourhood and fired four shots, killing officers Rafael Ramos and Wenjian Liu. He then ran into an underground station where he killed himself.
Hours earlier he had shot and wounded his ex-girlfriend Shaneka Thompson, 29, at her home outside Baltimore, then made threatening posts online, including a vow to put “wings on pigs” and references to the Brown and Garner cases.
Baltimore police warned the NYPD that Brinsley was in the city and bent on violence, but police chiefs were still getting the word out to officers when Brinsley struck.
Ms Thompson is in a critical condition at a Baltimore hospital.