The man invited passers-by to embrace him on the street where Isis militants ploughed into crowds killing 13 people last week.
He stood by a sign that read: "I am Muslim, I am not a terrorist. I share hugs of love and peace."
The words were written in Catalan, Spanish, English, Arabic and French.
Footage of the unidentified man hugging strangers has been viewed more than 7.7m times since it was posted on Facebook on Sunday.
Another woman who encountered the man wrote on Facebook: "When I hugged him, he asked me to forgive him.
"No innocent person should have to be forced to apologise for something he has not done. I was only able to cry and thank him."
The man's gesture echoes the reaction of other Muslims following previous Islamist terror attacks.
In November 2015, a blindfolded man wearing a sign that read, "Do you trust me?" hugged mourners in Paris following the co-ordinated attacks that claimed 130 lives at the Bataclan venue and other locations in the French capital.
In May this year, video blogger Baktash Noori spent hours giving out "free hugs" to strangers in Manchester following the deadly bombing at an Ariana Grande concert.
On Monday thousands of Muslims joined vigils in Barcelona to condemn terrorism and show their support for victims of the attack in the Catalan city and the seaside resort of Cambrils.
The crowd of about 2,500 held placards reading "we are also victims," "terrorism has no religion," and "we are all Barcelona, not terrorisms."
Many took to the streets chanting "not in my name."
Join our new commenting forum
Join thought-provoking conversations, follow other Independent readers and see their replies