Moments before he ambushed and killed two New York police officers, gunman Ismaaiyl Brinsley told bystanders to follow him on Instagram and then said, "Watch what I'm going to do," investigators said Sunday.

The disclosure came as police sketched a timeline of Brinsley's activities in the hours before he shot and killed Officers Wenjian Liu and Rafael Ramos in Brooklyn on Saturday. Brinsley later killed himself.

The killings have raised tensions in New York. The head of the police union, Patrick Lynch, said there was "blood on many hands" and blamed the mayor, who infuriated some police officers in public remarks after a grand jury declined to indict an officer in the chokehold death of a man last summer.

Investigators said Brinsley, 28, shot his ex-girlfriend at her apartment outside Baltimore after an argument, then took a bus to New York. On the way, he called the victim's mother to apologize, and she alerted Baltimore police, New York Chief of Detectives Robert K. Boyce told reporters.

Baltimore County police discovered that Brinsley had the ex-girlfriend's cellphone and was using it to post messages on his Instagram account that were threatening to the NYPD. One read: "I'm putting wings on pigs today. They take 1 of ours … let's take 2 of theirs."

Baltimore County police alerted the NYPD at about 1:30 p.m., and sent the NYPD a fax - which warned, "Please use extreme caution. Threats on police," - at 2:46 p.m. "A minute later is the homicide," Boyce said.

After telling two bystanders to "watch what I'm going to do," Brinsley passed Liu and Ramos' patrol car, then circled back and fired four shots into the vehicle, Boyce said. The gunman was pursued by power company workers, who flagged down police nearby. They chased him into the subway, where he turned the gun on himself. Six shells were missing from the firearm, Boyce said.

Brinsley had been arrested 19 times in two different states, Boyce said. His mother, who lives in Brooklyn, "expressed fear of him," and told investigators that her son may have had undiagnosed medical issues and was possibly on medication.

On social media, Brinsley occasionally ranted against police and government, Boyce said, mentioning one post that showed a burned American flag. Other posts referenced Michael Brown, the unarmed black teenager killed by a police officer in Ferguson, Missouri, and Eric Garner, who died after the chokehold.

Boyce said no evidence shows Brinsley has participated in any of the protests that sprang up after the deaths of Brown and Garner.

At the scene of the shooting, people laid flowers, candles and signs on Sunday. New York Police Commissioner Bill Bratton visited the memorial and said he was "very appreciative of the community outpouring. "We have to stay strong," one mourner told Bratton. "With your help I can try to do that," he said.