An off-duty NYPD detective was busted in Queens on Friday morning for allegedly stalking his ex-girlfriend — bombarding her with hundreds of emails and making her “feel like prey” after she called off their four-year relationship.

Brian Erbis, 46, was collared shortly before 8:45 a.m. on stalking and harassment charges, police said.

He was in a relationship with the woman from 2012 until February 2016, when she broke up with him, according to a criminal complaint filed in Queens criminal court.

Prosecutors allege he harassed the woman since then — inundating her with hundreds of emails and text messages and forcing her to eventually change her email address.

Erbis allegedly turned up at the woman’s house in September 2016, yelling, honking his car horn and demanding she speak with him.

The ex told him to back off and said his behavior was making her “feel like prey.”

His alleged harassment only escalated, however, and in June 2017, Erbis requested a transfer to an NYPD unit located next to hers, court papers say.

According to the complaint, he regularly tried to talk to his ex at work, and “constantly loitered near the elevators.” In December 2017, he emailed her saying “you should be careful,” the papers charge.

In April 2018, the woman made a complaint to the Erbis’ boss and he was placed on modified duty. Erbis — who made $140,000 in 2018, according to the non-profit Empire Center — was suspended without pay following the arrest, law enforcement sources told The Post.

His lawyer did not respond to request for comment.