A man who allegedly opened fire on police was shot when officers returned fire, sending him to the hospital, according to law enforcement sources.

The initial gunshots were fired after 3 p.m. on Bainbridge Avenue between East 194th Street and East 196th Street in the Fordham neighborhood, officials said. The suspect, later identified as Victor Soto, had gotten into an altercation inside the bodega, then returned with a gun, police said at a later press conference.

He pointed the gun at people inside the shop, then went outside, where he banged on one of the windows with the gun, according to NYPD Assistant Chief Aneudy Castillo.

A patrol car passing by at the time saw what was happened and immediately stepped in, said Castillo. Two officers ordered Soto to drop the gun, but instead he pointed at the cops.

It was not immediately clear who fired first or how many shots were fired, according to police, but it was the officers’ bullets that struck Soto. He was taken to a nearby hospital where he was said to be recovering.

Two officers were taken to Jacobi Hospital for tinnitus, a source said. A handgun was recovered at the scene.

The 49-year-old Soto was said to be well-known to police, with eight previous arrests.

An investigation is ongoing. It was not immediately clear what charges Soto might face.