An off-duty NYPD police officer was shot twice in an attempted carjacking while sitting in a white Range Rover on Bradford St. near Hegeman Ave. in the east neighborhood of New Lots in Brooklyn on Tuesday evening, authorities said.

The officer was with his cousin when a BMW pulled up behind them and one or two armed men exited the vehicle and approached the victim’s car and tried to open the door. He was struck twice at around 10:30 p.m.

The off-duty officer who works for the housing bureau in north Brooklyn is being treated at Brookdale Hospital in Brownsville.