NEW YORK—The man who strode up to a mobile police command post and fatally shot an NYPD officer Wednesday had ranted in a Facebook video last September about law officers killing and abusing people and warned them to leave him alone or “we gonna do something.”

“I’m not playing, Mr. Officer. I don’t care about 100 police watching this,” 34-year-old ex-convict Alexander Bonds said, adding: “It’s time for people to wisen up.”

Ten months later, Bonds went up to the RV-like command post in the Bronx and ambushed Officer Miosotis Familia, shooting her through the passenger-side window as she wrote in her notebook around 12:30 a.m.

New York City Police Commissioner James O’Neill said Familia was “assassinated in an unprovoked attack on cops.”

Familia’s partner frantically radioed for help, and officers caught up with Bonds about a block away and killed him in a hail of about 20 bullets when he pulled a stolen revolver, police said. He didn’t get off a shot, authorities said. The burst of gunfire as the Fourth of July wound down was initially mistaken by some for fireworks.

Familia, 48, was a 12-year veteran of the force who spent her entire career with the department in the high-crime Bronx precinct. The command post there had been set up and staffed around the clock since a triple shooting in March.

“She was on duty serving this city, protecting people, doing what she believed in and doing the job she loved,” Mayor Bill de Blasio said.

Police said they were trying to establish the motive for the shooting.

While tensions have been running high in recent years between police and black people around the country, there was no immediate indication the killing had a racial dimension. Bonds was Black; Familia was Black and Hispanic, her family having come from the Dominican Republic. She apparently had no previous contact with him.

Still, the attack recalled the 2014 ambush killings of two New York City officers who were gunned down in their cruiser by a man who had announced online moments before that he was planning to shoot two “pigs” in retaliation for the police chokehold death of Eric Garner in New York. The gunman, 28-year-old Ismaaiyl Brinsley, then killed himself.

Attorney General Jeff Sessions called Familia’s killing a “murder in cold blood.”

“Sadly, it is the latest in a troubling series of attacks on police officers over the past two years. These attacks must stop,” he said in a statement.

Bonds was seen on video leaving a convenience store, then moving tightly along the wall, pulling a hoodie over his head and walking purposefully toward the command post vehicle with gloved hands, according to police. The video didn’t capture the shooting itself but showed him running away with a gun in his hand, police said.

All new patrol cars rolled out by the department have bulletproof glass, and older vehicles are being fitted with window inserts to harden them against gunfire. But there are no plans to do the same with the rolling command centres, officials said.

Bonds had been paroled in 2013 after being sentenced to eight years in prison for a 2005 armed robbery in Syracuse. He had other arrests, including one in 2001, when as a teenager he was accused of attacking an officer with brass knuckles.

While his Facebook page is filled largely with inspirational quotes and quizzes, he alluded to his troubled past.

“Just few years ago I was in the devil house,” he noted in a New Year’s Eve post thanking God and people who had helped him.

But months earlier, he posted his rambling tirade full of bitterness over how inmates are treated in prison.

“Don’t think every brother, cousin, uncle you got that get killed in jail is because of a Blood or Crip or Latin King killing them. Nah, police be killing them and saying that an inmate killed them,” he said in the video.

Loading... Loading... Loading... Loading... Loading... Loading...

Prison records show he had been written up more than two dozen times for disciplinary reasons behind bars, mostly for relatively minor infractions, but some for violations such as assaulting an inmate or fighting.

Familia had three children, including twins, lived with her mother and worked the midnight shift. Friends said she became an officer to help her community, and her family was heartbroken.

“She was the sweetest person you ever want to meet,” downstairs neighbour Tom Ritter said.

He said his son, now 22, played with Familia’s children and she practically “adopted” him.

Even a woman who said her husband had been arrested by Familia had only kind words for the slain officer.

“She gave me good advice, like a mother to a daughter,” said Keisha Williams, who said her husband was arrested on a marijuana charge. “She’s good, but she’s a tough cookie. She’s a good cop. I’m just sad it was her.”