An NYPD officer is recovering at a Brooklyn hospital after being shot during an early morning incident Friday that also left a civilian seriously injured, authorities said.

Police said they received a call around 5:45 a.m. reporting shots fired inside an apartment on Kosciuszko Street, between Marcy and Tompkins avenues, in Bedford-Stuyvesant.

When officers arrived, they heard gunfire coming from inside the apartment, according to police. A man armed with a firearm then barricaded himself inside.

The NYPD Emergency Service Unit and a hostage negotiation team responded to the scene as the situation continued to escalate, police said.

An officer was struck in the left leg at some point during the standoff, police said. EMS transported him to NYC Health + Hospitals/Kings County, where he was reported to be in stable condition, the NYPD said.

The FDNY said a civilian also suffered serious, life-threatening injuries and was taken to NYC Health + Hospitals/Woodhull.

Police said the situation was declared no longer active around 10 a.m., though the investigation remains ongoing.

Authorities are urging New Yorkers to avoid the area.