"Give me all your money man! Give me everything you got," the suspect yelled at the driver.
WFMZ reported the attempted armed robbery happened in Reading, Pennsylvania, on Monday at about 4:30 p.m.
"We can do this the easy way or the hard way, keep your hands where I can see them," the suspect told the driver. "I need it all right now if you don't want to die."
The taxi driver tried to explain that he had just started his shift and didn't have much money on him.
While the crime played out, neither of the men in the cab noticed a Berks County sheriff's cruiser sitting right behind them.
The deputy put his emergency lights on and got out of his car to approach the taxi cab.
The terrified taxi driver in the middle of chaos stopped and said, "There's a cop behind us."
The deputy pulled out his weapon and ordered the suspect out of the vehicle.
"Oh my God you're a lifesaver," the cab driver told the deputy.
Victor Herrea, 18, was arrested and jailed on numerous charges including robbery and making terroristic threats.
Officials later determined the weapon was in fact a pellet gun. The victim was not hurt during the incident.