Barcelona police are treating a knife attack on officers at a city police station as a terrorist incident.
Commissioner Rafel Comes said officers shot the man dead after he entered the station in Cornella district and pulled out a knife.
Mr Comes said the man shouted "Allah" and other words that officers did not understand.
Police said the man "intended to attack police officers".
Police have found no evidence linking the incident to last year’s terror attacks in Barcelona and nearby Cambrils, which killed 16 people.
Intelligence services are helping with the investigation.