President Obama and Attorney General Eric Holder have condemned the shooting deaths of two New York City police officers who were ambushed as they sat in their patrol car in Brooklyn Saturday. 

"Two brave men won't be going home to their loved ones tonight, and for that, there is no justification," Obama said in a statement while vacationing with his family in Hawaii. "The officers who serve and protect our communities risk their own safety for ours every single day - and they deserve our respect and gratitude every single day."

Authorities say that before shooting the officers in Brooklyn's Bedford-Stuyvesant neighborhood, the gunman announced online that he planned to shoot two "pigs" in retaliation for the police chokehold death of Eric Garner. The gunman later killed himself.

In a statement Saturday night, Holder called the attack "cowardly" and said it underscores the dangers that are routinely faced by those who protect and serve their fellow citizens.

"Our nation must always honor the valor -- and the sacrifices -- of all law enforcement officers with a steadfast commitment to keeping them safe," Holder said. "This means forging closer bonds between officers and the communities they serve, so that public safety is not a cause that is served by a courageous few, but a promise that's fulfilled by police officials and citizens working side by side."

U.S. Attorney Loretta Lynch, Obama's choice to succeed Holder as Attorney General, said the attack "struck at the heart of our city -- the dedicated officers who pledge their lives to safeguard us all."

"Let us take this time to grieve with their families," Lynch's statement concluded, "and join the NYPD and all New Yorkers in honoring them for their sacrifice."

The Associated Press contributed to this report.