The officers mistakenly suspected he had a weapon, a police statement said, adding that they do not expect to open a terrorism investigation.
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”.
“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.