Pedestrians walk past the church where a man was killed the day before in Algeciras, southern Spain, on January 26, 2023. AFP
Spanish prosecutors immediately opened a terror probe following the incident near the city's port on Wednesday evening.
The attacker was arrested at the scene, with a police source identifying him as a 25-year-old Moroccan man.
The suspect arrested in connection with church attacks in Spain that killed a verger and wounded a priest was served with a deportation order last June, officials said on Thursday.
The suspect had "no prior criminal or terrorism convictions in Spain or allied countries" and was not under surveillance, Spain's interior ministry said.
"Just after 7:00 pm (1800 GMT), 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."
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.
The two churches are several hundred metres apart and located in an area very close to the port in this 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".
A police source told AFP the assailant was wearing a long robe and had "shouted something" as he carried out the attack.
Attacker shouted, threw icons
Eyewitnesses at Nuestra Senora de La Palma told local media the attacker ran into the building at around 7:30 pm and shouting, began throwing icons, crosses and candles to the floor.
The mayor of Algeciras has declared a day of mourning and called residents to gather for a demonstration of condemnation at midday (1100 GMT) in front of the church where the verger died.
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 by a demented lunatic and not something premeditated".