KABUL, Afghanistan — The leader of the Islamic State affiliate in Afghanistan who orchestrated audacious attacks that further upended the country’s deteriorating security situation was killed in a special forces raid last month, the president of Afghanistan said in a statement on Sunday.

The militant leader, Abdul Hasib, had overseen a number of bloody attacks that directly challenged the authority of President Ashraf Ghani, including a massacre at the main Afghan Army hospital in Kabul that killed at least 50 people.

Mr. Hasib was killed in an operation on April 27 in eastern Nangarhar Province, along the border with Pakistan, according to the statement by Mr. Ghani’s office. The statement said the government had waited for verification that Mr. Hasib had been killed in the raid before announcing his death. It did not say how his death had been confirmed.

The United States military command in Afghanistan said in a statement on Sunday that American forces had participated in the raid that killed Mr. Hasib and up to 35 other militants.