A plainclothes NYPD officer was shot and gravely injured early Sunday in a shootout with a suspect at the Edenwald Houses in The Bronx.

The injured officer, a six-year police veteran whose name was being withheld by The Post, suffered multiple gunshot injuries, law enforcement sources said.

He was rushed to Jacobi Hospital, where he was in surgery early Sunday.

The suspect, whose name was not immediately released, was taken to Montefiore Hospital, where he was pronounced dead, sources said.

Gunfire rang out at just after 12:30 a.m. near the 47 Precinct at Laconia Avenue and East 229 Street, according to witnesses and NYPD radio transmissions.

At least four shots, possibly as many as ten, were heard in quick succession — “pop-pop-pop-pop,” witnesses told The Post.

Rushing outside or to their windows, residents saw an officer in plain clothes laying on the ground near a suspect; both had been shot.

“There was a cop lying on the floor and another guy who looked like he’d been shot in the eye,” said witness Sara Diaz, 56. “Oh my god, I got so nervous.”

Radio transmissions recorded the worried panic of officers at the scene.

“Shots fired shots fired shots fired guys! I need a bus! I need a bus!” a male officer shouted, using police jargon for an ambulance.

“Laconia and 229!” another shouted of the shooting location.

“At first it was one shot. Then two seconds later it was followed by continuous shots — like, one-two-three-four-five-six. And then I see this car — I think it was a Jeep — drive off,” said Pedro Gonzalez, 18.

Some half-dozen cop cars rushed to the scene. Officials did not immediately disclose details of the shooting or the officer’s condition.