KABUL - A U.S. official said Friday he is convinced the Islamic State affiliate in Afghanistan carried out this week's horrific attack on a maternity hospital in a majority Shiite Muslim neighbourhood in Kabul, killing 24 people, including newborn babies and mothers.

Peace envoy Zalmay Khalilzad said the U.S. government believes IS was behind Tuesday's attack on the hospital and an assault earlier the same day in the country's east that targeted the funeral of a pro-government warlord, killing 34 people.

The Islamic State group “has demonstrated a pattern for favouring these types of heinous attacks against civilians and is a threat to the Afghan people and to the world,” Khalilzad tweeted. He did not elaborate further.

IS has not claimed responsibility for the Kabul attack, which Doctors without Borders - a Paris-based charity that operates the hospital - called “pure hell.” The organization, which also goes under its French acronym MSF, said gunmen headed straight to the maternity wards, ignoring units closer to the entrance of the medical complex, searching out the newborns and the mothers.

“They went through the rooms ... shooting women in their beds. It was methodical. Walls sprayed with bullets, blood on the floors in the rooms, vehicles burnt out and windows shot through,” said Frederic Bonnot, head of MSF programs in Afghanistan. “They came to kill the mothers.”

One of the attackers was just 16 years old, said Abdul Habib Faizi, the head of the hospitals' nursing department. He said it seemed the killers knew the layout of the hospital, moving floor to floor, throwing up to eight grenades as they went, storming the room where women were breast-feeding their babies and gunning them down.

The IS affiliate in Afghanistan is based in eastern Nangarhar province and mostly targets the country's minority Shiites. In 2018, IS killed dozens of young students taking university entrance exams in the same Dasht-e-Barchi neighbourhood of Kabul.

The militants have also issued past warnings to Shiites, threatening to kill them in mosques, schools and homes.

The IS claimed responsibility for the attack on the funeral in Nangarhar while the Taliban denied involvement in either attack, calling the carnage at the maternity hospital a “vile, inhumane and an un-Islamic act.”

A Taliban statement on Friday slammed Afghan President Ashraf Ghani for blaming the Taliban for the Kabul attack and accused him of trying to scuttle a U.S.-Taliban peace deal aimed at ending nearly 20 years of war.

Khalilzad, the architect of the deal signed Feb. 29, warned in a series of tweets early Friday that IS opposes peace between the Taliban and the Afghan leadership in Kabul and “seeks to encourage sectarian war as in Iraq and Syria.”

The U.S.-Taliban deal, signed on Feb. 29, provides for the withdrawal of U.S. and NATO troops from Afghanistan and has been touted as the country's best chance at peace in four decades of war.

But relentless political turmoil in Kabul has dogged the start of the second, critical phase of the deal, which calls for Afghans on both sides of the conflict to negotiate a framework for a post-war Afghanistan.

Both Ghani and his rival in last September's presidential polls, Abdullah Abdullah, have declared themselves winners and have both been sworn in as president. They have been unable to come up with a power sharing deal even as Washington has said it will reduce $1 billion in aid if they don't end their squabbling.

Washington's efforts to get the Taliban to reduce their violence have also been unsuccessful, though the insurgents have mainly targeted the Afghan military and not U.S. and NATO troops.

The withdrawal of U.S. and NATO troops, which started after the February deal was signed, is to continue until all troops are gone by the end of next year - if the Taliban keep their promise to fight against militant groups, most notably IS.

Meanwhile, MSF has suspended its operations in Dasht-e-Barchi, the charity told The Associated Press.

“This was a necessary but difficult decision knowing that women and children in Kabul are now deprived of a fundamental health care service they need, in a context where access to essential care is already limited,” said Filipe Ribeiro, MSF country representative said in a TV interview with the AP.

The group said it will review its operations following an investigation into the attack.

Gannon reported from Islamabad