Fighters from al-Shabab killed 20 people when they targeted the popular Lido beach resort.
The demonstrators, who turned out to support the victims, shouted slogans including "al-Shabab has no religion".
Lido beach's popularity has been seen as a sign of a return to normality in Mogadishu after years of conflict.
It attracts thousands of mostly young Somalis who come to relax and enjoy the beach and the surf.
Al-Shabab said it targeted the resort's restaurants because they are frequented by government officials.
A spokesperson for Mogadishu's city government, which organised the rally, told BBC Somali that people had gathered to show their "defiance".
"They wanted to show their disapproval of what happened here, which was a massacre of innocent Somali people," Abdifitah Omar Halane said.
Al-Shabab, which is part of al-Qaeda, was ousted from Mogadishu in August 2011, but still has a presence in large areas of southern Somalia.
Mogadishu's Lido beach: Sun, surf and... grenades?
Who are al-Shabab?
Al-Shabab divided by IS call
A group of Somalis have held a peace rally at the site of last week's militant Islamist attack in the capital, Mogadishu.