Two New York City police officers, Wenjian Liu and Rafael Ramos, were shot dead "execution style" in Brooklyn just before 3 p.m. Saturday, police said, by an alleged gang member who posted on social media that he wanted revenge for the deaths of Michael Brown and Eric Garner.

"Quite simply, they were assassinated," NYPD Commissioner Bill Bratton said at a press conference held Saturday evening at the hospital where the grieving families gathered. "Both officers paid the ultimate sacrifice today while protecting the communities they serve."

Liu and Ramos may have never seen the attacker open fire as they were sitting in their patrol car, Bratton said, on special duty because of heightened violence in the area.

Liu, age 32, was a seven year veteran of the force, the NYPD Deputy Commissioner of Public Information said in a statement. Liu was married only two months ago, according to Bratton, who met with the fallen officer's devastated parents and new bride. Ramos, who just had his 40th birthday, became a cop only three years ago after working for years as a school safety officer. He was a two year veteran of the NYPD, the DCPI said. Ramos' family includes a wife and 13-year-old son, "who couldn't comprehend what had happened to his father," New York City Mayor Bill de Blasio said.

The mayor called the shooting "a particularly despicable act."

"When a police officer is murdered, it tears at the foundation of our society," de Blasio said. "It is an attack on all of us. It is an attack on everything we hold dear. We depend on our police to protect us against forces of criminality and evil."

The gunman, identified by police as Ismaaiyl Brinsley, 28, opened fire on Liu and Ramos while they were sitting inside a marked, parked squad car outside of the Tompkins Houses, a public housing project in Brooklyn's Bedford-Stuyvesant neighborhood. Other officers chased Brinsley, but he ran into the Myrtle/Willoughby G train subway station and shot himself in the head. He was pronounced dead at The Brooklyn Hospital Center, Bratton said.

The NYPD released a photo of the weapon used on the officers later Saturday night.

“The perp came out of the houses, walked up behind the car and lit them up,” a high-ranking police official told the Daily News. "He approached from behind, opened fire and clearly his intent was to assassinate them," an official told the New York Times.

Two NYPD cops sitting in patrol car in Brooklyn shot by gunman in "ambush" shooting: sources. http://t.co/dksNV2sczApic.twitter.com/KeW8LGbkCa — New York Daily News (@NYDailyNews) December 20, 2014

“I seen them putting the cop in the ambulance. He looked messed up,” eyewitness Derrick McKie told the New York Post. “He took a high caliber weapon to the face. He was lifeless…I couldn’t see where the holes was that, all I could see was blood. His body was lifeless.”

Ramos and Liu were rushed to Woodhull Medical Center in critical condition, but the trauma staff was unable to save either man.

Brinsley may have been a member of a Baltimore gang called the Black Guerilla Family, sources told the Daily News.

Brinsley also allegedly referenced the deaths of Garner and Brown hours before he opened fire in Brooklyn. On an account linked to the shooter's ex-girlfriend, Brinsley posted a photo of a silver handgun and a threatening message to police: "I’m Putting Wings On Pigs Today. They Take 1 Of Ours...Let’s Take 2 of Theirs."

Rev. Al Sharpton was quick to condemn the killing, saying "any use of the names Eric Garner and Michael Brown, in connection with any violence or killing of police, is reprehensible and against the pursuit of justice in both cases."

Brown's family also issued a statement: "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."

President Obama said in a statement, "I unconditionally condemn today's murder of two police officers in New York City. Two brave men won't be going home to their loved ones tonight, and for that, there is no justification."

Saturday's shooting might have been prevented, Bratton said, because Baltimore County detectives tried to warn the NYPD that Brinsley had shot his former girlfriend in Maryland, had connections to Brooklyn's East Flatbush area and was now targeting police. But the warning -- in the form of a fax machine message that included a photo -- came too late.

"Just as the warning was coming in, the murder was occurring," Bratton said during the somber press conference.

A 29-year-old woman was shot in the stomach in Owings Mills, Baltimore early Saturday morning. Local police told the Baltimore Sun that they were not immediately able to confirm whether Brinsley was involved in that shooting.

Brinsley was not from Brooklyn, though Bratton said that he may have some connection to the area. As far as police could tell, Brinsley's last residency was Georgia, Bratton said, though he seems to have moved around frequently. "We're still trying to put together his movements and where he's been over past few months," he added.

BREAKING: Two police officers shot "execution style" in Bed-Stuy. Gunman killed http://t.co/4DuYDVzsZHpic.twitter.com/cfkZH2ZUOP — New York Post (@nypost) December 20, 2014

A witness who was on the first car of a Court Square-bound G train when police were on the scene told The Huffington Post that he saw "crowds of people lined up squatting against the wall" and "trying to hide behind benches" on the platform as his train pulled in.