King Felipe, Prime Minister Mariano Rajoy and Catalonia's president Carles Puigdemont led the ceremony mourning the 14 people killed by terrorists who used vehicles to mow down pedestrians in Barcelona's Las Ramblas boulevard on Thursday and in the nearby seaside resort of Cambrils early Friday.
"These have been days of tears, many tears," said auxiliary bishop Sebastia Taltavull.
Outside the church, snipers were posted on rooftops surrounding the landmark building by Gaudi, while heavily armed police stood guard as hundreds of people gathered under grey skies.
Catalonia resident Teresa Rodriguez said she had turned up to pray for the victims.
"What happened in Las Ramblas is really hard for us, we go for walks there often, it could have happened to me, my children or anyone. And here we are. It's huge, huge," she said as she fought back tears.
Later Sunday, nearly 100,000 people were expected at Barcelona's Camp Nou stadium for their team's first game of the season, to be marked by a minute of silence for the victims.
Interior Minister Juan Ignacio Zoido said Saturday the cell behind the carnage that also injured 120 had been "dismantled," although local authorities took a more cautious tone.
Police were still hunting 22-year-old Younes Abouyaaqoub, who media reports say was the driver of a van that smashed into crowds on the popular Las Ramblas boulevard on Thursday, killing 13 people.
Hours later, there was a similar assault in the seaside town of Cambrils that left one woman dead. Police shot and killed the five attackers, some of whom were wearing fake explosive belts.
An extensive security operation including roadblocks was mounted overnight across Catalonia.
The ISIS group claimed responsibility for the attacks, believed to be its first in Spain.
The terror cell in Spain reportedly comprised at least 12 young men, some of them teenagers.
Investigators are seeking to unravel the role of an imam, Abdelbaki Es Satty, who is believed to have radicalised many of the youths from a small town called Ripoll, at the foot of the Pyrenees.
Several of the suspects -- including Abouyaaqoub -- grew up or lived in the town of about 10,000 inhabitants.
On Saturday, police raided the imam's apartment in Ripoll, his flatmate, who would only identify himself as Nourddem, told AFP.
Spanish media quoting police sources, said the officers were looking for DNA traces in the apartment to compare with body parts found in an explosion in a home in Alcanar, about 200 kilometres (120 miles) south of Barcelona, where the alleged terrorists were believed to have been building bombs.
Police said they believed the suspects were planning a much larger attack.
"They were preparing one or several attacks in Barcelona, and an explosion in Alcanar stopped this as they no longer had the material they needed to commit attacks of an even bigger scope," said Josep Lluis Trapero of Catalonia's police.
Security forces were seen removing dozens of gas canisters from the house in Alcanar on Friday.
The imam was also known to police, according to Spanish media, which reported that he had spent time in prison.
El Pais and El Mundo quoting anti-terrorist forces said the imam had met prisoners linked to the March 2004 Al-Qaeda-inspired bombing attack on commuter trains in Madrid that killed 191 people, the worst terror attack in Europe.
A clearer picture is emerging of the suspected perpetrators.
Most of them are children of Moroccan immigrants, including Ripoll-born Moussa Oukabir, 17, one of five suspects shot dead in Cambrils. His older brother Driss is among the four arrested.
In Morocco, Moussa and Driss's father Said broke down, surrounded by relatives.
"I hope they will say he's innocent... I don't want to lose my two sons," he told AFP.
A cousin said Moussa "loved playing football, having a good time, chatting up girls".
He travelled to Morocco almost every year for the summer holidays and was expected back last Tuesday.
"The last few months, he started to become interested in religion. He used to go to a mosque in Ripoll. Maybe that's where he was brainwashed," the cousin said.
Security ramped up
Victims of the attack came from three dozen countries including Algeria, Australia, China, France, Ireland, Peru and Venezuela, reflecting Barcelona's status as Spain's most popular tourist destination.
Fifty-four people are still in hospital, including 12 in critical condition, Catalan emergency services said.
With the peak summer tourism season still in full swing, the Spanish government ordered security ramped up in crowded places, although it kept the terror threat level at four out of a maximum five.
Tourism has been vital to Spain's economic recovery, and because it has until now been spared the wave of extremist attacks that hit Europe, it has recorded a surge as visitors shunned more restive destinations such as Tunisia and Egypt.