KABUL, Afghanistan — Through a persistent rain in the Afghan capital on Wednesday, thousands of protesters carried the coffins of seven beheaded Hazara hostages to the presidential palace, demanding greater security and an end to a wave of targeted violence.

The crowd in Kabul — huge by the standard of recent years — shouted slogans including “Death to the Taliban” and “Death to the Islamic State.” They accused President Ashraf Ghani of incompetence in the face of deteriorating security and called for the resignation of his coalition government.

“For too long, we have been buried in silence,” said Mohamad Ishaq Mowahidi, one of the protest organizers. “The logical way is for us to submit the coffins as a gift to the government.”

Though most of the demonstration remained orderly, frustrations rose late in the day, when a smaller group of young protesters smashed the windows of government buildings with stones and scaled walls to enter the palace parking lot. A spokesman for Mr. Ghani, Sayed Zafar Hashemi, said 10 protesters were wounded when palace guards fired warning shots.