A retired NYPD detective sitting in a Bentley with bulletproof glass got into a gunfight with a man he says tried to swipe his Rolex in Brooklyn Sunday, police said.

Former Detective Robert Santos told cops he was in his 2010 luxury ride outside his dad’s home in East New York at about 3:50 a.m. when “a guy walks up, points a gun at him and says, ‘Give me your Rolex,’ ” a high-ranking police source told The Post.

Santos, 46, “puts the watch on the seat. He then gets out of the car and gets into a gunfight with the guy,” the source said.

The would-be robber — described as between 35 and 45 years old and last seen wearing light-colored clothing — fled, police said.

Cops were scouring hospitals in case he was struck by a bullet, sources said.

The cop, who retired in 2013 after 21 years, wasn’t shot — but his 2010 Bentley took a few slugs. He was taken to an area hospital for ringing in his ears.

In 2011, when Santos was still with the NYPD, he pulled a gun on the estranged husband of now-Assistant Chief Juanita Holmes, who suspected his wife and Santos of having an affair.

Santos was also in a Chelsea nightclub when a person was shot to death in 2011, but he left before talking with cops and was kicked off the NYPD’s Joint Terrorism Task Force, sources said.