The southern Spanish city of Algeciras was reeling today, a day after a machete-wielding assailant stormed into two churches killing an official and badly injuring a priest.

Spanish prosecutors immediately opened a terror probe following the incident near the city's port yesterday evening.

The attacker was arrested at the scene, with a police source identifying him as a 25-year-old Moroccan man.

"Just after 7pm (6pm Irish time), a man entered the church of San Isidro in Algeciras, where, armed with a machete, he attacked the priest, leaving him seriously wounded," an interior ministry statement said.

"Subsequently, he entered the church of Nuestra Senora de La Palma in which, after causing damages, he attacked the verger [church official]."

Eyewitnesses at Nuestra Senora de La Palma told local media the attacker ran into the building at around 7:30pm and began throwing icons, crosses and candles to the floor.

The verger, Diego Valencia, "managed to get out of the church, but was caught by the attacker outside and sustained mortal injuries," it said, identifying the weapon he used as a machete.

A police source said the assailant was wearing a long robe and had "shouted something" as he carried out the attack.

The two churches are several hundred metres apart and located in an area very close to the port in the town of around 120,000 residents.

The emergency services said the priest had sustained injuries to the neck.

His parish identified him as 74-year-old Antonio Rodriguez and said he had been celebrating the Eucharist at San Isidro church when he was attacked, describing his condition as "serious but stable".

Police secure the area near the church in Algerciras
Police secure the area near the churches in Algerciras

The mayor of Algeciras has declared a day of mourning.

In the town, which hosts the main port for ferries and other vessels travelling between Spain and Morocco, residents reeled from shock.

Juan Jose Marina, the parish priest of Nuestra Senora de La Palma, told public radio the idea of such an attack was unimaginable "because our ties with the Islamic world in Algeciras are good and we've never had any sort of problem".

"It just defies all logic," agreed Dris Mohamed Amar, spokesman for the local Muslim community, who was speaking on the same radio programme, saying he hoped "it was an isolated case".