An off-duty NYPD officer chased and shot at a man who allegedly approached him with a knife after a car crash on Long Island, authorities said.

The off-duty officer had seen a crash on the Southern State Parkway in Bay Shore on Sunday night and had pulled off to help the drivers before Suffolk County police could get on scene, according to police.

When the cop got out of his car, one of the drivers tried to leave the scene. The cop told the driver, later identified as 40-year-old Sean Burke, that he was an officer and that he shouldn't leave, and Burke allegedly took off on foot.

Suffolk County police said that the officer chased after Burke into a neighborhood near the parkway.

When the two got to a backyard on Joan Road, Burke allegedly pulled out a knife and approached the officer. The officer then fired his service weapon but the gunfire didn't hit Burke, who ran off a second time.

Police tracked down Burke on a service road for Sunrise Highway in neighboring West Islip 3 hours later. Police allege the man still had a knife on him at the time.

Burke was arrested and charged with menacing a police officer and drug charges. He was scheduled to be arraigned on Monday.

Attorney information for the man wasn't immediately available.

The off-duty officer wasn't charged with any crimes.