Gunmen killed at least 27 people and wounded 29 more in Afghanistan's capital on Friday at a remembrance ceremony for a minority Shiite leader, officials said.

Heath Ministry spokesman Wahidullah Mayar said the injured had been taken to hospitals in Kabul. All of the casualties were civilians, said Interior Ministry spokesman Nasrat Rahimi.

Several prominent political leaders escaped the ceremony unhurt, including Abdullah Abdullah, the country's chief executive and a top contender in last year's presidential election.

INTERNATIONAL CRIMINAL COURT GIVES GREEN LIGHT TO INVESTIGATE US FOR ALLEGED WAR CRIMES IN AFGHANISTAN

Afghan security forces were still trying to flush the gunmen out of a half-finished apartment building, Rahimi said. Dozens of Afghan security forces had cordoned off the area.

The Taliban have denied they were behind the attack, and while no one has claimed responsibility for carrying it out, Afghanistan's upstart Islamic State affiliate has declared war on the country's minority Shiites. Most of the people attending the memorial service were Shiite.

The attack 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.

JOE BIDEN CONFRONTED BY VETERAN OVER IRAQ WAR SUPPORT: 'BLOOD IS ON YOUR HANDS!'

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.

GET THE FOX NEWS APP

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.