As he pulled out of the Prince George’s County Police Department’s District 3 station, homicide Detective Mike Ebaugh thought he heard a cry for help. By police’s telling, he rolled down his car windows and followed the noise.

Ebaugh eventually traced the sounds to a crime in progress: A man was beating another, nearly lifeless man with a shovel. Ebaugh drew his gun, police said, and ordered the attacker to stop.

He did.

Police are now crediting Ebaugh — who investigates killings for a living — with possibly preventing a homicide. The man being beaten survived the Saturday attack, though he remained hospitalized Monday, police said.

The incident occurred about 10:30 p.m. In a blog post, police said Ebaugh was leaving the station at 7600 Barlowe Road when he heard the noises, which he traced to Allendale Drive and Barlowe Road.

The calls for help soon gave way to the sound of metal striking something, police said. That is when Ebaugh saw the beating in progress, police said.

Police said that after Ebaugh intervened, he called for help, arresting the shovel-wielder and giving medical care to the victim.

Police identified the attacker as David E. Hamilton, 48, of Palmer Park, and said he has been charged with first-degree assault.