WATCH: Hero Starbucks customer wrestles thief after hitting him with a chair

CCTV has been released showing a "courageous hero" whacking an armed man in an Optimus Prime mask in an attempted Starbucks robbery.

Cregg Jerri, 58, was several metres away when he saw suspect Ryan Michael Florez, 30, produce a knife and allegedly threaten an employee at the California Starbucks, The Fresno Bee reports.

Although the thief is pointing a pistol at the employee, he pulls out a knife while demanding they fill his plastic bag with cash.

Security video from Thursday shows Jerri pick up the chair as he walks past a table still being wiped down by a Fresno Starbucks employee while her colleague is being held up.

The alleged thief approaches the counter wielding a knife and gun-shaped item. Source: Fresno Police

Jerri walks up to the suspect, who has his back turned to focus on the heist, and whacks him with a chair on his back, knocking the Transformers disguise from his head.

The unmasked robber turns around in shock and starts to wrestle with Jerri only to find himself in a headlock.

Hero Cregg Jerri, 58, is seen with his daughters. Source: Facebook
The customer hits the thief with a chair. Source: Fresno Police

Jerri drops the chair as the two men begins pushing, shoving and punching each other before falling to the ground.

Florez allegedly stabbed Jerri in the neck during the altercation, requiring stitches.

The two begin to wrestle. Source: Fresno Police

But Jerri, who reportedly works in sales and is regular customer, gained control of the knife and stabbed the suspect several times, police said.

When showing the video to the public, Chief Dyer described Jerri as a "courageous hero" and a "pleasure to talk to".

"It's good to talk to heroes," he told the Fresno Bee.

Police said Florez got in a truck and drove away but was later found bleeding on the side of the road.

The pair were both stabbed in the incident. Source: Fresno Police
Jerri managed to knock Florez to the ground. Source: Fresno Police

Florez fled the scene after the altercation but allegedly later told them he was a victim of the robbery.

He was later identified as the thief with the help of the CCTV footage.

Fresno police Chief Jerry Dyer said that Florez has no criminal record as an adult.

Florez is expected to be charged with attempted armed robbery and assault with a deadly weapon.