Claimed in the name of the Islamic State organization, these attacks were committed by a dozen young Moroccans radicalized by an imam.
The crowd observed a minute of silence - disturbed by a handful of protesters - on the Ramblas, the main artery of the Catalan metropolis, where the deadliest attack took place, which claimed the lives of 14 people.
To the sound of traditional Catalan music, relatives of several victims and officials placed white carnations in front of the commemorative plaque placed on the sidewalk.
The central government was represented by two ministers, Raquel Sánchez (Transport) and Miquel Iceta (Culture and Sports), alongside the president of the regional government of Catalonia, the separatist Pere Aragonès, and the mayor of Barcelona, Ada Colau.
Socialist Prime Minister Pedro Sánchez, currently on vacation, joined in the tribute with a tweet, calling on his compatriots to remain "united for freedom and living together".
"In August 2017, Barcelona and Cambrils", a seaside town 100 km further south, "had suffered from hatred and terrorism in their streets", he said. "Five years later, we remember the victims of these attacks, while continuing to build a future of peace."
In an interview with National Television, Ms Colau said that August 17 would never again be a day like any other in Barcelona. "Now, on August 17, you always wake up with a knotted stomach," she said.
The first attack took place on the Ramblas, where a ram-truck drove into the crowd, killing 14 people, mostly foreign tourists. The youngest victim had been a three-year-old child.
In his escape, the driver had killed a motorist to steal his car. He was to be shot by police three days later 30 km north of Barcelona.
A few hours after this massacre, five other members of the cell carried out a second attack on the Cambrils seafront, knocking down several people with a vehicle before fatally stabbing a woman.
The three survivors of the jihadist cell had been sentenced to eight, 46 and 53 years in prison.
But last month, a court reduced the sentence of the two main convicts on appeal by ten years, also recalling that under Spanish law, their effective sentence could not exceed 20 years in prison.
The third convict was released in September 2021.
The minute of silence was disturbed by the slogans and cries of some demonstrators who held up placards demanding "the truth". They had responded to the appeal of independence associations which claim that the Spanish state was behind the attacks.