The match — the final of a city-wide club tournament for 16- to 18-year-olds — took place at the Konis Stadium, which has been renovated by FIFA.
It was broadcast live on several television channels but took place under tight security because of the threat posed by the Shabaab Islamist group.
“Tonight is a historic night which people waited for more than 30 years. I tell you that Mogadishu is secure and people deserve more than this,” Mayor Tabit Abdi Mohamed said after the match, which saw Waberi beat Hodon 3-0.
“There are thousands and thousands of people who are out here tonight to watch this football game. We will continue making history.”
Omar Ibrahim Abdisalam, a spokesman for the Somali Football Federation, said the last night game in Mogadishu had been staged back in 1988.
The federation hopes Friday’s game will open the door to similar matches.
“It is a step towards peace and stability after so many years in the darkness,” local resident Hanad Gulled said before the encounter.
“If Somalia can once again consider matches in the evening in Mogadishu, then we are not so far from returning to the former peaceful days.”
But Gulled admitted that for safety reasons, he would watch the match on TV.
The Shabaab have shown in recent months that they have the capacity to carry out large-scale attacks in the centre of the capital, using vehicles stuffed with explosives or armed groups.
Since the fall of President Siad Barre’s regime in 1991, Somalia has been plunged into chaos and violence, supported by clan militias, criminal gangs and Islamist groups.
The Shabaab want to defeat the fragile Somali central government, backed by the international community and the 22,000 troops of the African Union Mission to Somalia (AMISOM).
They were driven out of Mogadishu in August 2011 and later lost most of their strongholds, but they still control vast rural areas.
Download our app and read this and other great stories on the move. Available for Android and iOS.