An NYPD officer was shot in the leg by a suspect who barricaded himself inside a home in Brooklyn, according to law enforcement sources.

Police had responded to a house on Kosciusko Street in Bed-Stuy just before 6 a.m. after getting a report of shots fired inside the home, sources said. When officers arrived, a 48-year-old man flashed a gun, and the officers ran for cover.

The man barricaded himself inside the house. Hours later, just before 9 a.m., an officer was shot in the leg and taken to the hospital, according to law enforcement sources. The cop’s condition was not immediately clear, but was expected to survive.

The suspect was shot as well and later died, police said.

It was unclear if the suspect was still barricaded in the home. The NYPD’s hostage negotiation team was at the scene as the investigation continued.