Interior Ministry spokesman Nusrat Rahimi said some of the victims may have died, but details remained sketchy.
Several prominent political leaders escaped the ceremony unhurt, including Abdullah Abdullah, a top contender in last year's presidential election.
Afghan security forces had cordoned off the area, and were trying to flush the gunmen out of a half-finished apartment building in which they were hiding.
The Taliban denied involvement in the attack. It came just days after the United States and the Taliban signed an ambitious peace deal that lays out a conditions-based path to the withdrawal of American forces from Afghanistan.
The Islamic State group has attacked Afghan Shiites in the past, and views the religious minority as heretics. Any U.S. troop pullout would be tied in part to promises by the Taliban to fight terrorism and IS.
Friday's ceremony was held in the mostly Shiite Dasht-e-Barchi neighborhood of the capital, Kabul.
The memorial marked 25 years since the death of Abdul Ali Mazari, the leader of Afghanistan's minority ethnic Hazaras, who are mostly Shiite Muslims. He was killed in 1995 by the Taliban as they moved to take control of Kabul, which had been destroyed by a brutal civil war among mujahedeen groups, including Mazari's.