Two New York police officers have been shot dead in Brooklyn, in what is being described as an apparent ambush.

The shootings come amid anger over the chokehold death of an unarmed black father-of-six by a white police officer, and a grand jury's decision not to press charges against him. Local media said the assailant was also dead.

"Our prayers are with our fellow NYPD brothers who were executed in the line of duty today in Brooklyn," the New York Police Department's 66th Precinct posted on its official Twitter page.

Earlier, NYPD spokesman Sergeant Lee Jones told AFP news agency that "we can confirm that two police officers were shot at 2:50pm (7:50pm Irish time) at the corner of Myrtle and Tompkins in the 79th precinct".

Local media reported that the officers were shot as they wore their uniforms and sat in their marked police car while working overtime as part of an anti-terrorism drill.

They were shot at point-blank range by a single gunman who approached their patrol car.

The attacker is reported to have fled on foot towards a metro station, where he was shot and killed. It is not yet clear if he shot himself.

A grand jury's decision not to indict the white officer over the 17 July death of Eric Garner triggered mass protests in New York and other US cities.

The move followed a similar verdict in Ferguson, Missouri that sparked riots there and demonstrations in cities across America.

The St Louis suburb has been a hub of protest and racial tensions since unarmed black 18-year-old Michael Brown was shot dead on 9 August by a white police officer.

Last month, a rookie police officer fatally shot Akai Gurley, an unarmed 28-year-old black man, in the stairwell of a Brooklyn apartment building.

These cases, along with the death of a 12-year-old black boy, who was gunned down by police officers in Ohio while handling a toy pistol in a playground, have inflamed underlying disgruntlement in the US in relations between police and African Americans.