NEW YORK — An NYPD officer was shot in the face and killed Wednesday morning in the Bronx while sitting in a marked police vehicle with her partner, the Police Department said.

“Police Officer Miosotis Familia has been assassinated in an unprovoked attack on cops assigned to keep NYers safe,” NYPD Commissioner James O’Neill said in a statement. “Keep her family in your prayers.”

Officer Miosotis Familia in an undated photo. Associated Press/Courtesy of the New York Police Department

A man walked up to the police vehicle at 183rd Street and Morris Avenue about 12:30 a.m. and fired one shot from a handgun, hitting the 12-year veteran, O’Neill said. Her partner radioed for help, he said.

A senior NYPD official said later that the motive of the shooter, Alexander Bonds, 34, a Bronx resident, was nothing more than, “I just hate cops.”

Before the shooting, Bonds was seen going into a bodega, exiting, pulling up his hoodie and then walking over to the police vehicle, officials said.

Familia, 48, and her partner were sitting in what is called “a command vehicle,” which is about the size of a motor home and is meant to be a visible presence in a neighborhood, police said.

Police said the vehicle had been in the area since March because of gang-related shootings.

After the shooting, Bonds encountered a uniformed police sergeant and a uniformed officer about a block away and drew a revolver, O’Neill said.

“The officers fired at him, striking and killing him,” the commissioner said. “A silver revolver was recovered at the scene.”

A bystander was hospitalized in stable condition after being struck by a bullet during the officers’ encounter with Bonds, O’Neill said.

Bonds complained in a video blog about police harassing youngsters, and the way police officers in California had pulled a 16-year-old off a bicycle, officials said.

Bonds was on parole from a robbery conviction in the Syracuse area, police said. He was arrested in Queens in 2001 for assaulting a police officer, officials said. He also was arrested in 2005 in Onondaga County on a robbery case, violated parole in 2006 and was sent to the Attica Correctional Facility, officials said.

He was released in May 2013 and had encounters with police for minor offenses, including public urination and alcohol use, officials said.

Corrections records indicate he was also known as “John” Bonds.

The police commissioner and Mayor Bill de Blasio spoke at a news conference at St. Barnabas Hospital, where the wounded officer died. The mayor said that he and the commissioner met with the officer’s family.

Outside Familia’s house in the Bronx, Carlos Corporan, Familia’s brother-in-law, said the family is devastated. “She was loved,” he said.

Gov. Andrew M. Cuomo and de Blasio extended their condolences to the Familia family and praised the fallen officer for her service to the city.

Patrick Lynch, president of Familia’s union, the Patrolmen’s Benevolent Association, said she “stood tall against those who threaten and terrorize the good folks of the Bronx.”

“Police Officer Miosotis Familia, the mother of three, gave her life protecting a neighborhood that had been plagued by gun violence,” Lynch said.

Police said they knew of no connection between the suspect and the officer.

De Blasio and O’Neill visited Familia’s 46th Precinct to meet with her colleagues. The mayor’s spokesman, Eric Phillips, said de Blasio was there to show his “solidarity” with the officers, and listen to them.

The mobile command center where Familia was shot remained parked on East 183rd Street between Creston and Morris avenues. The vehicle’s right-side door glass was shattered, and it lights remained flashing hours after the shooting.

Kim Jamie, 45, a Bronx native who has lived in the neighborhood for the past year, said she heard the shot but assumed it was fireworks.

“You can’t distinguish the fireworks from the shooting,” Jamie said.

As Jamie passed uniformed officers at the corner of 182nd Street and Morris Avenue, she said to them: “Sorry for your loss.”

Outside the 46th Precinct where Familia worked, officers with sullen faces exchanged hugs and consoled one another. Flowers lined the steps of the precinct station on Ryder Avenue just blocks from where Familia was killed. A blue- and black-striped banner was draped across the front entrance.

Several pastors arrived at the precinct shortly before 12:30 p.m. to hold an impromptu prayer service for Familia and her mourning colleagues. The Rev. Terry Lee of Brooklyn, speaking to reporters outside the precinct building, described a somber scene inside. “You can feel the pain … it’s a painful moment,” Lee said.

He said he did not know Familia but felt compelled to come to the police station to offer prayers upon hearing she was a mother.

The Rev. Kelly Scott of the Way to Life Ministries in Harlem said she was there to pray “for the strength” of Familia’s family. “Officer Familia is a hero,” Scott said.