A police officer has been shot and wounded inside a precinct in the Bronx, New York, hours after another officer was shot while sitting in a patrol car in the same area.

A man walked into the 41st precinct headquarters on Sunday morning and opened fire. A police lieutenant was wounded in the arm and has been taken to Lincoln Hospital, where he is reported to be in a stable condition. A suspect was arrested and is in custody.

It was not immediately clear whether there was any connection with a shooting near by on Saturday evening on Simpson Street, in an area covered by the same precinct.

Media reports suggest that police believe the same man may be responsible.

A man in a black jacket and hat reportedly approached two officers in a patrol car, asked a question and then opened fire.

One officer was hit in the neck and chin and taken to hospital. He was expected to be released later on Sunday – although it was revealed one bullet came close to hitting his carotid artery. Neither officer returned fire and the gunman escaped.

​New York city mayor Bill de Blasio tweeted: "This vicious assassination attempt is the second one we've seen in 24 hours — and an attack on our NYPD officers is an attack on ALL New Yorkers.

"This despicable hatred is an attempt to divide our city and undermine our safety. We cannot and will not let that happen."

NYPD commissioner Dermot Shea told a news conference: "By the grace of God, we are here talking about an officer that will be going home.

"Let me be very clear: this was an assassination attempt of two New York city police officers. It is a miracle we are not here under worse circumstances."

Pictures of the suspect in the first shooting released by police and video purporting to show the attack on the precinct show bearded men of similar build, wearing jeans, black shoes and a black beanie hat but different coloured jackets – black in the street shooting, orange and blue in the second.

The attack on the squad car recalls previous fatal attacks on New York City police officers.

In 2017, a gunman killed Miosotis Familia as she sat in her patrol vehicle in the Bronx. In 2014, two officers, Rafael Ramos and Wenjian Liu, were shot dead in their patrol car in Brooklyn by a man upset about recent police killings of unarmed black men.

Mr Shea said Ramos and Liu's deaths were "not something that engenders anything but the worst memories".