Police officers shot a 34-year-old man early Sunday who was allegedly attacking his girlfriend with a knife in the Bronx.

The man, who was not identified, was allegedly attacking the 32-year-old woman with an 8-inch knife inside a building on Sedgwick Avenue at about 3:50 a.m., police said.

The couple spilled from the stairwell into the lobby of the building, near West 195th Street, police said.

Cops ordered him to stop, police said, but he refused. Two officers then shot at the man, striking him in the torso.

Each officer shot at him once, police said.

Both the man and his girlfriend were taken to St. Barnabas Hospital in stable condition. The officers were taken to New York-Presbyterian/The Allen Hospital and treated for tinnitus, or ringing in the ears, police said.

The couple has children together, police said. It is unclear what spurred the attack.

The knife was recovered between the second floor landing and the lobby, police said.