The man had entered the police station in Cornella "with the aim of attacking the agents," Catalonian police said on Twitter.
It is still unclear if the man was killed.
According to the newspaper La Vanguardia, a suspect may be a native of Algeria.
On August 17 2017, Spain's Barcelona and Cambrils faced two van ramming attacks, which have killed 15 people and left more than 130 injured. The Daesh claimed responsibility for the attacks.
More about: Spain