Image copyright Police photos Image caption Police say Alexander Bonds (L) fatally shot Miosotis Familia before he was killed in a police shootout

A New York police officer has died after she was shot in the head in an "unprovoked attack" while sitting in her car on duty, police said.

Miosotis Familia, 48, was taken to hospital where she was pronounced dead hours after the shooting.

The suspect, Alexander Bonds, 34, fled the scene before he pulled out a revolver and was shot dead by police.

A bystander was also struck in the stomach by a bullet during the police shootout, according to police.

Police said the person is in stable condition.

"This was an unprovoked direct attack on police officers who were assigned to keep the people of this city safe," Police Commissioner James O'Neill said at a news conference.

How often are US police killed on duty?

Ms Familia, with 12 years of experience at the department, was nearing the end of her shift in the Bronx neighbourhood early on Wednesday morning when Bonds walked up to her vehicle and fired a shot through the passenger-side window.

Image copyright Reuters Image caption The suspect fired a round into the passenger window and shot Ms Familia in the head, police say

Her partner immediately called for help as Bonds ran from the scene. He was about a block away when police confronted him and he pulled out a revolver, according to Mr O'Neill.

The officers fatally shot Bonds and a silver revolver was found at the scene.

The ex-convict, who also went by the name of John Bonds, was sentenced to six years in prison for an armed robbery case in Syracuse and had been released on parole in 2013.

In a video posted to his Facebook account in September, Bonds ranted about poor prison conditions and unfair police treatment.

He also suggested he would not back down in his next police confrontation.

"I'm not playing, mister officer," he said into the camera. "I don't care about 100 police watching this."

Bonds was also convicted in 2004 for the criminal sale of a controlled substance near a school, according to state prison records.

In 2001, he was arrested and accused of attacking an officer with brass knuckles.

Image copyright Reuters Image caption Ms Familia worked in the 46th police precinct

Surveillance footage early on Wednesday showed him pulling his hooded sweatshirt over his head before walking up to the vehicle "with purpose". Police said a motive is still unclear.

Ms Familia was a mother-of-three who also took care of her elderly mother and had previously worked for two years for the American Red Cross, report local media.

"She was on duty serving this city, protecting people, doing what she believed in and doing the job she loved," New York Mayor Bill de Blasio told reporters at the hospital before she died.

"And after this shocking and sudden attack, her fellow officers came to her aid immediately."

When asked whether the attack could be described as an assassination, Deputy Chief Jason Wilcox said: "Everything is pointing to that."

The shooting recalled a 2014 attack on two New York police officers sitting in their patrol car in the Brooklyn neighbourhood of Bedford-Stuyvesant.

Wenjian Lui and Rafael L Ramos were killed by a man who travelled from Baltimore and had vowed to kill police officers.

Ismaaiyl Brinsley, who had a history of mental illness, shot both officers before turning the gun on himself.