The man was reportedly carrying gasoline and gunpowder in his pockets as he entered the Mercadona shop, in As Lagoas.
Numerous shoppers were inside making their purchases when the armed assailant entered and fired several shots.
A supermarket employee said the man, who was standing just a few metres from him, yelled “Allahu Akbar”, which translates to “God is greatest”.
Police arrived at the scene to arrest the attacker.
One witness told local media: “Agents came out with a vest shouting and pushing the people.”
Officer Carlos Perez, who was already at the supermarket, revealed he was fired at when he tried to stop the attack.
The 38-year-old revealed the attacker was only apprehended after his colleagues arrived.
He said: “I had the impression that he ran out of ammunition.”
Police sources told local media the gunman is believed to have psychological problems and is a neighbour in the area.
This is a breaking news story. Please refresh the page for updates.