An NYPD officer gave a gunman the shock of his life Saturday, tasing him when he pressed a pistol to the belly of his partner during a tense traffic stop on the Lower East Side, police said.

Police Officer Joseph Stokes and Police Officer Daniel Amaral were driving along Columbia Street near Rivington Street at around 6 a.m. when they spotted a a 2013 white Dodge Challenger, with the same plates of a car the NYPD said was connected to an April 28 shooting in Washington Heights.

The car was unoccupied at the time, so they called for back-up — Police Officers Jose Aracena and Luis Perez — and then waited for the driver, identified by police as 28-year-old Amado Zubidi, to return.

“Three officers were on the driver’s side of the suspect’s vehicle and Officer Perez [on] the passenger’s side,” said Capt. Aaron Edwards, executive officer of the 7th Precinct, where the officers are assigned, at a media availability later in the afternoon.

“Knowing that the person linked it the vehicle could be armed and dangerous, the officers were prepared,” he continued.

Zubidi, who was alone at the time, initially refused to get out of the car, prompting Amaral, Stokes and Aracena to try to pull him from the driver’s seat, police sources said.

A struggle ensued, and Zubidi allegedly grabbed a loaded .38-caliber revolver that was on the floor of the car, and pressed it against Aracena’s gut, the sources said.

Perez — who had his Taser at the ready as a precaution — immediately fired it at Zubidi, quickly immobilizing him, the sources said.

“This could have turned out very, very differently,” said a source with knowledge of the case, who added the officers’ actions “saved everyone’s asses.”

Video obtained by the Post shows Zubidi shouting in pain as he’s carted into a waiting ambulance. He was briefly taken to Bellevue Hospital Center to have the Taser’s sharp prongs removed.

One of the police officers was also taken to an area hospital for elbow pain, cops said.

Zubidi was charged with attempted aggravated murder of a police officer, criminal possession of a weapon and resisting arrest, cops said.

Investigators confirmed Zubidi was the suspect in the April shooting incident, in which he allegedly fired his gun at someone in another vehicle, cops said. Police charged him with reckless endangerment and criminal possession of a weapon.