Two NYPD officers were shot and killed on Saturday afternoon, in what NYC Police Commissioner William Bratton called “execution-style.” The suspect, Ismaaiyl Brinsley, was later found shot to death in a nearby subway station.

NEW YORK — Two New York City police officers died Saturday afternoon after being shot “execution-style” while in a parked patrol car in Brooklyn.

In a somber press conference Saturday evening, New York City Police Commissioner William J. Bratton said the two officers were deliberately targeted. He also acknowledged the danger officers face as part of the “thin blue line between us and anarchy.”

“They were, quite simply, assassinated, targeted for their uniform and the responsibility they embraced,” Bratton said. “Both were ambushed and murdered.”

Bratton said the attacker approached the officers’ vehicle from the passenger side and opened fire, shooting his weapon several times. The officers, Wenjian Liu and Raphael Ramos, “never had an opportunity to draw their weapons” and were “killed with no warning, no provocation,” he said.

“They may have never even seen their assailant, their murderer,” Bratton said.

The suspect, Ismaaiyl Brinsley, 28, fled to a nearby subway station, where he was found dead of a self-inflicted gunshot wound, Bratton said.

Earlier Saturday, Brinsley shot his former girlfriend, injuring her at a Baltimore County, Md. residence, Bratton said. Brinsley also posted on the victim’s Instagram account, where his comments indicated Brinsley had a “very strong bias against” police, Bratton said. The postings will be investigated as authorities search for a motive.

The New York shooting happened around 3 p.m. in the Bedford-Stuyvesant neighborhood in Brooklyn at the corner of Myrtle and Tompkins avenues. Bratton said they have seen no connection to terrorist groups or any other organized entity.

New York Mayor Bill de Blasio said the shooting was an attack on all New Yorkers.

“When a police officer is murdered, it tears at the foundation of our society. It is an attack on all of us,” said de Blasio, who has had a rocky relationship with rank-and-file police officers over what they see as his lack of support. “When they are attacked, it is an attack on the very concept of decency.”

The last time an NYPD officer was shot to death in the line of duty was in December 2011, when 22-year veteran Peter Figoski was shot in the face while responding to a report of a break-in at a Brooklyn apartment. The triggerman, Lamont Pride, was convicted of murder and sentenced in 2013 to 45 years to life in prison.

Police blocked off a several-block radius around the shooting scene and shut off trains to the subway station nearby. Helicopters hovered overhead while residents peered over police tape in curiosity.

Bedford-Stuyvesant resident Derrick McKie said he was coming out of a restaurant about a block from the scene when he heard four or five gunshots. He saw police cars speeding and rushed to the commotion. McKie said he saw one officer being carried into an ambulance in a stretcher.

“He was lifeless — he wasn’t moving,” said McKie, 49. “Blood covered his face.”

“It was very chaotic, police scrambling,” he added.

Eddie Perez stood outside the police tape taking pictures of the distant investigation scene with his phone. He grew up in the housing projects adjacent to the shooting scene and said he had never seen the neighborhood as it was on Saturday night.

“It looks like a war zone — disgusting,” said Perez, 61, who now lives in the Bergen Beach section of Brooklyn. “It’s just senseless.”

In a statement and series of tweets, Rev. Al Sharpton condemned the violence. Sharpton and his National Action Network have been prominent voices in calling for police reform following the deaths of Michael Brown in Ferguson, Mo., and Eric Garner in New York.

“I am outraged at the killing of 2 police officers in Brooklyn. That is why we stress non violence as the only way to fight for justice,” he tweeted Saturday evening. “An eye for an (eye) leaves the whole world blind. We all at NAN express our prayers and condolences to the families of the 2 NYC officers.”

Benjamin Crump, lawyer for the Brown family, released a statement late Saturday.

“The family of Michael Brown condemns today’s senseless killing of two NYPD officers.We reject any kind of violence directed toward members of law enforcement. It cannot be tolerated. We must work together to bring peace to our communities.Our thoughts and prayers go out to the officers’ families during this incredibly difficult time.”

The White House said President Obama was briefed on the shooting while golfing in Hawaii, where he and his family are spending Christmas vacation, and that advisers “continue to monitor the situation.”

The shooting comes at a time when police across the USA are being criticized for their tactics following widely publicized deaths of unarmed black men.

A little more than a week after a Missouri grand jury decided in November not to indict officer Darren Wilson in the death of 18-year-old Brown, a New York grand jury chose earlier this month not to indict officer Daniel Pantaleo in the death of Garner.

The decisions kicked off widespread, ongoing demonstrations across the country that have included protests, marches and die-ins inside malls and other buildings and along major highways, where protesters have brought traffic to a standstill.

Brinsley was black; the officers were Asian and Hispanic, police said.

Coco Reds, a Bedford-Stuyvesant resident, said the area is as safe as any other in New York but tensions have been heightened by gentrification. Reds, a black man and a construction worker, said he has been taken into custody and later released by police when he was doing nothing wrong.

“That’s what the police presence is for — in order to keep people like me away from people like them,” Reds said, referring to newer neighborhood residents.

Contributing: Gregory Korte in Washington, D.C.; Kevin McCoy in New York City, Trevor Hughes in Denver; The Associated Press. Lackey reported from McLean, Va.