A man wielding a knife and shouting in Arabic was shot dead as he entered a police station south of Barcelona, Spanish authorities said on Monday.
The attacker, said to be 29 and of Algerian origin, had gone into the building at 05:52 (03:52 GMT) and was shot by an officer on duty.
Catalan police said the attacker had targeted officers. He had shouted “Allahu Akbar” (God is greatest), reports said.
The attacker lived in the town of Cornellà de Llobregat, just south of Barcelona. He had been living in Spain for several years and had a foreigners’ identity number, reports said.
He was named as Abdelouahab Taib by Spanish media, which said he had no known criminal record and lived with a Spanish woman.
The attacker had walked through the building’s entrance where he was immediately challenged by a woman officer with the Catalan force, the Mossos d’Esquadra, and by a sergeant on duty, police sources told the Efe news agency. When the man rushed forward, he was shot.
Police stations across Spain were put on alert as a result of Monday’s incident.
Members of the Catalan police force and other authorities searched the man’s home a short distance from the police station while his partner was questioned, local reports said.
The attack came three days after the anniversary of the 2017 jihadist attacks in the centre of Barcelona and nearby Cambrils in which 16 people died. The attacks saw a man drive a van into civilians on Las Ramblas in the heart of Barcelona on 17 August. He was eventually tracked down and shot dead four days later.
Teresa Cunillera, the Spanish government’s representative in the north-eastern region of Catalonia, refused to be drawn on the motive for Monday’s incident until police had investigated further. “Reaching conclusions is very hard before they have carried out the minimum of checks and looked into the motives,” she told Spanish radio.