An off-duty NYPD housing cop was shot and wounded Tuesday night during a stickup in Brooklyn, authorities said.

Officer Tramaine Oxley, 33, was hit in his left forearm and grazed in the chest near 737 Bradford St. in East New York when bullets started flying about 10:30 p.m., according to officials.

“It appears now that it was a straight-up robbery attempt on a number of individuals sitting in a parked car, including one of our police officers,” NYPD Commissioner Bill Bratton said Wednesday.

Oxley, who had just left a nearby basketball game with his family, had been sitting in a white Range Rover with his cousin on Linden Avenue near Bradford Street when a blue BMW pulled behind them.

Two armed men jumped out of the BMW and approached their vehicle before attempting to open the door, sources told The Post.

The cop identified himself as an officer, pulled his own weapon and was wounded in an exchange of gunfire, sources said.

The thugs swiped cash, jewelry and a cellphone from their victims, then ran back to the BMW, sources said.

The Range Rover, in which Oxley was sitting as a passenger, left the scene to get away from the crooks after the robbery, said Chief of Department James O’Neill.

“They made a U-turn and on the way back the people that robbed them were in the middle of the street,” said O’Neill. “At some point, shots were fired at the Range Rover, and at an additional point, our off-duty [member of service] fired four rounds at the people that robbed him.”

Witnesses said they heard a barrage of seven or eight gunshots and noticed multiple cars fleeing the scene.

“I heard a bunch of commotion,” one witness said. “There was a bunch of shots and then cars zooming off.”

It was not immediately clear who fired first or whether the thieves were wounded.

Police canvassed the area for bullet casings. They also looked for the shooter and checked hospitals for gunshot victims.

Authorities have a partial New York license plate number to track the suspects down.

“It’s a dark-colored BMW 2006 to 2010 with a partial New York plate AA,” said O’Neill.

Oxley, an eight-year veteran who had a previous leg injury and was out sick, was driven to Brookdale University Hospital by his cousin.

He is expected to make a “full recovery,” said O’Neill.

He had worked the 8 a.m.-to-4 p.m. shift in East New York, where he was stationed at Police Service Area #2 on Sutter Avenue.

He was the latest cop to be shot this year, the most recent of whom was Officer Brian Moore, who was gunned down in May by a career criminal in Queens.