A masked man in Reading tried to rob a taxicab driver at gunpoint at exactly the wrong moment – and it was all caught on camera.

The dramatic video, recorded on Monday, shows the suspect pulling a gun and screaming at the terrified driver, telling him to hand over his money and wallet.

The driver pleads with the man, asking him not to shoot him.

As it turns out, a sheriff’s deputy happened to be stopped right behind the taxi as the incident unfolded.

The deputy realized something was not right and turned on his flashing lights.

The video shows him walking up to the taxi, pulling his gun on the suspect and forcing him out of the car.

The cabbie can be heard telling the deputy, “You’re a lifesaver!”

According to WFMZ-TV, the 18-year-old suspect has been charged with robbery, making terroristic threats and simple assault.

He’s behind bars on $100,000 bail.