The officers, identified as officers Wenjin Liu and Raphael Ramos, were on duty around 3 p.m. in Bedford-Stuyvesant near Tompkins and Myrtle Avenues.
Liu was married two months ago. Ramos just turned 40, and was an officer after three years as a school safety officer, said Bratton.
Authorities said the suspect in the shooting ran inside a subway station and fatally shot himself in the head. He was identified as Ismaaiyl Brinsley, 28, of Georgia.
VIDEO: Officers rushed to the hospital
It is unclear what led up to the shooting or where exactly it took place, but streets are shut down near Tompkins and Myrtle avenues.
New York City's police commissioner says the two officers who were ambushed and killed in their cruiser "were, quite simply, assassinated."
Police Commisssioner William Bratton spoke Saturday at a news conference with Mayor Bill de Blasio. He identified the two officers killed in Brooklyn as Wenjin Liu and Raphael Ramos. He says they were shot without warning or provocation.
Bratton says the suspect shot his ex-girlfriend earlier Saturday in Baltimore. There is possible surveillance video of the suspect. The NYPD will provide more details as they become available.
De Blasio called the two officers heroes.
PHOTOS: NYC officers ambushed
Police Commisssioner Bratton says the gunman who ambushed and killed two police officers had made online posts that were "very anti-police.
The shooting comes at a time when police in New York and nationwide are being heavily criticized for their tactics following the chokehold death of Eric Garner, a black man who was stopped by police for selling loose, untaxed cigarettes and could be heard on an amateur video gasping, "I can't breathe" as he was being arrested.
VIDEO: Resident speaks out over double police shooting
The Rev. Al Sharpton, president of National Action Network, released a statement following the shooting. "We have stressed at every rally and march that anyone engaged in any violence is an enemy to the pursuit of justice for Eric Garner and Michael Brown," said Sharpton. "The Garner family and I have always stressed that we do not believe that all police are bad, in fact we have stressed that most police are not bad."
One city councilman called the shooting in Brooklyn "the worst thing that could have happened."
VIDEO: Councilman speaks out after double police shooting
The last shooting death of an NYPD officer came in December 2011, when 22-year veteran Peter Figoski responded to a report of a break-in at a Brooklyn apartment. He was shot in the face and killed by one of the suspects hiding in a side room when officers arrived. The triggerman, Lamont Pride, was convicted of murder and sentenced in 2013 to 45 years to life in prison.
(The Associated Press contributed to this report)