Surveillance video shows the moment a man attempted to rob a convenience store with a knife, and was stunned to look up from the cash register to see a gun pointed right at his face.

The altercation happened at the Corner Mini Mart in Newton, Massachusetts.

The video shows the man walking into the store and right up to the owner, Charlie Patel, and threatens him with a knife.

What he didn't know is that the store has a regular customer who happens to be on the local police force, and also happened to be in the back of the store at the time of the attempted robbery.

The man is seen digging through the cash register as Newton Police Lt. Dave Tempesta sneaks up to him with his gun drawn.

A struggle ensued when 30-year-old Thomas Zekos tried to make a run for it, but Tempesta and Patel wrestled him to the ground.

And it was all caught on video.

"The Lt. began struggling with the suspect and had to discard his firearm behind the store counter until the clerk and two customers … who walked into the store in the middle of the incident came in and assisted him," Newton police said.

"Once other units arrived and the suspect was in custody Lt. secured his firearm and the knife was gathered as evidence," the police added.

Patel says that Tempesta is a good friend of his in addition to being a regular customer.

"Thanks to my God. I love my cop. He's my heart," Patel told WBZ-4. "The cop is my heart."

Zekos faces numerous charges including armed robbery, assault and battery on a police officer and resisting arrest. He pleaded not guilty and admitted to police that he has a problem with addiction.

Patel said the officer had walked in only two minutes before the attempted robbery. He was off duty at the time.

Here's a local news report about the arrest: