A New York City police officer was ambushed and fatally shot in the Bronx, while sitting in a marked police vehicle. The attacker was later killed by officers, according to NYPD.

Officer Miosotis Familia was wrapping up her shift in a mobile command unit early Wednesday when the gunman walked up to the vehicle and fired a single round from a handgun through a passenger-side window, according to Deputy Chief Jason Wilcox, commander of detectives in the Bronx.

The bullet struck her in the head. She was rushed to hospital but died three hours later.

Sad to hear of the tragic loss of #NYPD Ofcr Miosotis Familia thoughts & prayers of are with her family, friends. pic.twitter.com/dWInRwSPo1 — Chief John Benedict (@jbLASD) July 5, 2017

"Shots fired! 10-85!" Officer Familia’s partner, Vincent Maher, shouted over the police radio after the gunfire, including the code for ‘officer down’, according to WABC-TV. "My partner's shot! My partner's shot! My partner's shot! Hurry up central!"

#NYPD officers end their painful hospital vigil and escort body of fallen officer's body to the morgue. @PIX11News#officerdownpic.twitter.com/sQyjHPGkjO — Anthony DiLorenzo (@ADiLorenzoTV) July 5, 2017

Two other officers encountered the attacker, who was running on the street in the Fordham Heights section of the Bronx. When the gunman drew his revolver, the police opened fire and killed him.

"Based on what we know right now, this was an unprovoked direct attack against police officers who want to keep this great city safe,” Police Commissioner James P. O’Neill told reporters, according to the New York Times.

Mayor Bill de Blasio speaking at the same news conference praised Officer Familia and expressed the city’s grief.

“She was on duty, serving this city, protecting people, doing what she believed in and doing the job she loved,” he said. “And after this shocking and sudden attack her fellow officers came to her aid immediately.”

Asked whether the attack could be characterized as an assassination, Chief Wilcox replied, “Everything is pointing to that.”

A bystander was hit in the stomach by a bullet in the shootout and is in stable condition, said Commissioner O’Neill.

The gunman was identified as Alexander Bonds, who also uses the name John Bonds. He served seven years in prison for robbery in the Syracuse area before he was paroled in May 2013, according to state records. Police said there was no indication he knew Officer Familia.

NEW DETAILS: More on the death of #NYPD Officer. New info on suspect w/ Syracuse ties. Watch @cnycentral @ #Noon. https://t.co/NA4HLk74br — Allison Bybee (@BroadcastBybee) July 5, 2017

In a video posted on Facebook in September, Bonds ranted about the treatment of civilians by officers and talked about how hard life was behind bars. The photos of Bonds posted on the page match a police mugshot, according to WABC.

"Don't think every brother, cousin, uncle you got that get killed in jail is because of a blood or crip or Latin King killing them. Nah, police be killing them and saying that an inmate killed them," he said in the video.

The Bronx neighborhood was blocked off with police tape as officers investigated the deadly shooting.

#NYPD detective downloading surveillance video from camera posted near scene of shooting that killed Officer Familia. pic.twitter.com/EPDNvKqRrC — Janelle Burrell (@BurrellTV) July 5, 2017

Witnesses in Fordham Heights said the violence had brought an abrupt end to July 4th holiday celebrations.

“At first I thought they were fireworks,” Roma Martinez, a longtime resident who was nearby when he heard gunfire told the New York Times. “I don’t know how many gunshots.”

“Within two or three minutes, the streets were completely filled with officers. After, we all left. The party was over,” Martinez added.

The attack resembles the December 20, 2014 killing of patrol officers Wenjian Liu and Rafael Ramos, who were ambushed and shot to death in their vehicle in the Bedford-Stuyvesant section of Brooklyn. Without warning, a man approached the passenger window of their marked police car and fired.

The suspect, 28-year-old Ismaaiyl Brinsley, then fatally shot himself. Brinsley announced online in the moments before the shooting that he was planning to shoot two "pigs" in retaliation for the police chokehold death of Eric Garner.

In another similar incident, two police officers were shot and killed in Des Moines, Iowa on November 2, in two separate ambushes. The gunman was sentenced to life in prison.

Fatalities of law enforcement officers are up 24 percent so far since 2016, with 67 dead, 24 of those deaths were firearm related, according to the National Law Enforcement Officers Memorial Fund.

Lawmakers in several states have introduced legislation that would make attacks on law enforcement a hate crime. Last December, a bill was introduced in California that would create stiffer penalties for those convicted.

The US Attorney General, Jeff Sessions, in a statement issued about the killing of Officer Familia said she was "unjustly targeted and murdered in a cowardly unprovoked attack."

"This murder in cold blood is a tragedy, and sadly it is the latest in a troubling series of attacks on police officers over the past two years," wrote Sessions. " These attacks must stop and we must honor the service of every law enforcement officer and the memory of those we have lost in the line of duty.”

Read more

Last July, five police officers were killed by a gunman in Dallas, and three more died in a rampage in Baton Rouge, LA. The shooting occurred during a time of high tensions between law enforcement and some communities over police killings of unarmed people of color.

Earlier in 2016, Louisiana adopted a measure dubbed the Blue Lives Matter bill, which made attacks on police officers a hate crime. Similar proposals are being considered in Texas, New Jersey and Mississippi, as well as in the US Congress, which can change the federal definition of a hate crime.

Groups including the American Civil Liberties Union have said such laws could dilute the original intent of hate crime measures to protect vulnerable classes of citizens.

“Our hate crime statute is simply not the proper home for these offenses,” Kevin Baker, legislative director of the ACLU California told the LA Times in December. “Police officer status is an employment category not analogous to the personal characteristics included in our hate crime statue, including disability, gender, nationality, race or ethnicity, religion, and sexual orientation.”