The man, of Moroccan origin, was travelling with a woman in a vehicle registered in France and approached the toll by the border town of La Jonquera in the north of the country in the early hours of Saturday morning.
Police said a Guardia Civil patrol was alerted because the man had a "strange" attitude and "seemed to be manipulating something inside the vehicle".
Non-Muslim men victims of Islamophobia because of their 'looks': research
"The police asked him to get out. He finally got out with something in his hands and he moved towards the officers," said a spokesperson for the Catalan police.
The spokesperson said that, according to the policemen present, the man "shouted Allahu Akbar '(God is greatest)".
"The police officers repeatedly asked him to stop, shot in the air to intimidate him but as he continued to move forward, they shot him in the hip," he said.
The man "then undressed" and "appeared to suffer from mental problems".
According to the Guardia Civil his life "is not in danger" and he is being cared for in a hospital in Gerone.
Police say an investigation is underway to establish the facts about what happened.
COMMENTS
Comments are moderated and generally will be posted if they are on-topic and not abusive.
For more information, please see our Comments FAQ