Watch: Starbucks customer fights off armed robber with a chair

Dramatic surveillance video shows a battle between a knife-wielding armed robber wearing a Transformers mask and a brave customer swinging a chair at a Fresno Starbucks Thursday.

The video (above) shows the suspect, identified as Ryan Flores by KFSN, approaching the barista waving a toy gun and a plastic bag. Seconds later, he pulls out a knife.

That's when customer Cregg Jerri intervened, picking up a chair and slamming it down on the would-be robber's head. Flores fought back as the two men wrestled over the knife.

During the fight, Jerri was stabbed in the neck, but is expected to recover, KFSN reports. Jerri was eventually able to take the knife away from the suspect and stabbed Flores several times before he got away.

ALSO READ: Surveillance video catches coyote attacking cute Maltese in SoCal backyard

"It's not something we recommend. In this case it was a good outcome-- no one died as a result of this incident, but very well could have," Fresno Police Chief Jerry Dyer told the Fresno news station. "But nonetheless, he's a hero-- there's no question."

Fresno police found Flores nearby. He was treated for injuries before being taken into custody.