A police officer shot an aggressive pit bull to death in Brooklyn, authorities said.

The incident happened when the officer and his partner showed up to an apartment on the 10th floor of a building on Plaza Street in Prospect Heights on Sunday morning looking for a suspect from an earlier crime, officials said.

When someone inside the apartment opened the door, the dog charged the cops, forcing one to draw his weapon and fire five shots at the animal, killing it.

A cab driver called police because a man who lived in the apartment skipped out on a fare, officials said. The hack brought the man home from The Bronx around 4 a.m., but the fare said he was out of cash, so he left his wallet with the driver promising to return with money, police said.

The guy never came back, and the cabby called police, who arrived a little before 4:30 a.m. — they knew the address because the man left his wallet with the driver, police said.

Neither officer was injured but both went to an area hospital for tinnitus, officials said.

No arrests have been made at this time.

The news comes days after a pit bull savaged a 3-year-old Rockland County boy after bolting from a house when his owner opened the front door.