The same day, in the country's east, a suicide bomber killed 24 people at a funeral.
The attacks cap a deadly six-week period since the Taliban and the United States signed a deal that leaders hoped would lead to a reduction in violence and the start of intra-Afghan talks. Instead, a spike in attacks by the Taliban and other militant groups such as the Islamic State have put the fragile chance for peace in jeopardy.
The Taliban denied responsibility for Tuesday's bloodshed, but Afghan officials appeared to connect the two attacks with rising Taliban violence in other parts of the country. Hours after the siege at the hospital ended, Afghan President Ashraf Ghani ordered his armed forces to resume offensive operations against the Taliban.
"This is not peace, nor its beginnings," Afghanistan's national security adviser Hamdullah Mohib said in a post on Twitter, referring to Tuesday's violence. He said that the Taliban "subcontracted their terror to other entities" and that there is "little point in continuing to engage Taliban in 'peace talks.' "
Those peace talks between the Taliban and the Afghan government were supposed to begin more than two months ago but have been plagued by delays. Key negotiations over a controversial prisoner swap collapsed in April, and while both sides have continued to release prisoners unilaterally, they don't appear any closer to direct talks.
In a statement Tuesday, Secretary of State Mike Pompeo condemned the hospital attack as "an act of sheer evil" and urged both sides to find a solution to the political crisis.
"The Taliban and the Afghan government should cooperate to bring the perpetrators to justice," the statement read. "As long as there is no sustained reduction in violence and insufficient progress towards a negotiated political settlement, Afghanistan will remain vulnerable to terrorism."
The public text of the U.S.-Taliban peace deal does not include a commitment from the Taliban to reduce attacks against Afghan forces, but U.S. officials have said all sides verbally agreed to bring overall violence down by as much as 80 percent.
Pentagon spokesperson Army Lt. Col. Thomas Campbell said Tuesday that the U.S. military would continue to conduct airstrikes in defense of Afghan forces despite the resumption of offensive operations.
"As the secretary of defense stated recently, this is going to be a windy, bumpy road," Campbell said, adding that a political agreement "is the best way to end the war."
The Taliban released a statement condemning Tuesday's attacks and calling Ghani's announcement a "declaration of war."
"The Kabul regime will be responsible for an increase in the violence," said spokesman Zabiullah Mujahid. He accused the Afghan government of delaying talks and "creating hurdles in the peace process," specifically over prisoner releases.
Any escalation in violence in Afghanistan also will complicate the response to the coronavirus outbreak. Increased clashes will make it more difficult for aid groups to deliver relief, as lockdowns have caused unemployment to soar and put millions at risk of hunger. Previous appeals from the United Nations for a humanitarian cease-fire have been ignored.
The future of armed groups such as the Islamic State in Afghanistan was a critical element of negotiations between the United States and the Taliban in the lead-up to the signing of the agreement in February. U.S. negotiators demanded assurances from the Taliban that terrorist organizations with aims of attacking the West would not be allowed to operate in territory under their control.
Ahead of the peace deal, U.S., Afghan and Taliban military pressure on the Islamic State crippled the group’s territorial hold and led to a sharp drop in large-scale attacks in Afghan cities. (In the Taliban’s statement Tuesday, Mujahid highlighted the role that Taliban fighters played in the military operations, a contribution that even U.S. officials assessed as “significant.”)
But recent deadly shootings in Kabul suggest some of the extremist group’s networks and cells remain intact.
In March, Islamic State gunmen killed 32 at an ethnic Hazara and Shiite gathering, and later that month gunmen stormed a Sikh temple, killing 25. Like the previous attacks, the hospital targeted Tuesday serves a minority community of mainly Hazara and Shiite Afghans.
And on Tuesday, the Islamic State asserted responsibility for a suicide bombing at the funeral of a prominent local security official in the eastern province of Nangahar, killing two dozen and wounding 68, according to the provincial governor's office.
The funeral was attended by government officials, including a member of parliament. A member of the provincial council was among the dead, according to two local officials who spoke on the condition of anonymity because they were not authorized to release information to the media. Nangahar was the focus of a months-long military push against the Islamic State last year.
Similar to previous attacks, the gunmen in the hospital Tuesday held off Afghan security forces for hours. More than 100 patients, family members, doctors and nurses were evacuated from the hospital during the attack. About four hours after the siege began, Afghan forces declared the building cleared.
The head of Afghanistan’s Independent Human Rights Commission, Shaharzad Akbar, condemned the brutality of an attack targeting newborns. She wrote in a post on Twitter, “Among their first experiences [is] being targeted in a war they & their mothers had no part in.”
Abdul Habib Faizy, the hospital's nursing manager, said he could hear the gunmen changing their weapons' magazines outside the safe room where he hid.
"It was a horrific situation," he said. "We were waiting to die every moment. Who would kill mothers who had just given birth and their newborn babies?
"They are the enemies of humanity," he said.
George reported from Islamabad, Pakistan.