Hector Rivaflecha Hechavarria has been charged with two counts of premeditated attempted murder with a deadly weapon. He is in critical condition at the Ryder Trauma Center.
After Hechavarria, 43, walked into the grocery store with the sword, announced he was going to kill everyone inside and then struck a woman on the back of her arm, 47-year-old Jose Antonio Mendoza sprang into action.
"The armed man turned to the security guard and hit him over the head," Miami police spokeswoman Kenia Reyes told the Miami Herald. "The armed security guard discharged his firearm striking the armed suspect several times."
The altercation spilled into the parking lot where police eventually arrived and arrested Hechavarria.
"He was doing his job," customer Andreas Fernandez said of Mendoza. "What else can I say? He was doing his job and he did it well."
Mendoza was in stable condition after being hit in the head.
"I feel this might be an isolated incident," shopper Mike Rodriguez told NBC Miami. "Everyone knows each other, the people who work in the meat, the dairy, the cashiers. So it's kind of a neighborhood atmosphere."