Afghanistan's floundering peace process appeared further in peril Tuesday, with security forces ordered to resume offensive operations against the Taliban in response to two attacks that were shocking even for a country numbed by decades of war.

At least 14 people were killed -- including newborns and nurses -- when gunmen stormed a maternity hospital in Kabul early Tuesday, officials said. Shortly after, a suicide blast at a funeral in the country's restive east left two dozen mourners dead.

No group immediately claimed responsibility for the bloodshed, but President Ashraf Ghani blamed the Taliban and the Islamic State group.

"Today, we witnessed terrorist attacks by the Taliban and Daesh groups on a hospital in Kabul and a funeral in Nangarhar, as well as other attacks in the country," Ghani said in a televised address, using the Arabic abbreviation for IS.

He ordered Afghanistan's security forces to end their "active defence position" and "return to offensive postures, and resume their operations against the enemy."

The move comes months after Afghan forces pledged to only react defensively to Taliban attacks.

Afghan security personnel arrive at the site of an attack outside a hospital in Kabul on May 12, 2020
Afghan security personnel arrive at the site of an attack outside a hospital in Kabul on May 12, 2020 AFP / STR

It was meant to show good faith ahead of eventual peace talks, but the Taliban did not reciprocate, instead unleashing a wave of violence that began the moment the insurgents signed a deal with the United States.

Ghani said offensive operations were needed to "defend the country, safeguard our countrymen and infrastructure, and to repel attacks and threats by the Taliban and all other terrorist groups."

Tuesday's first attack saw gunmen storm the Barchi National Hospital as parents brought infants and children for appointments.

The three attackers were eventually killed in a lengthy clearance operation. Heavily armed security forces were seen carrying infants -- at least one wrapped in a blood-soaked blanket.

"The fatalities also include mothers and nurses," interior ministry spokesman Tareq Arian said.

Map of Afghanistan locating Nangarhar province where fatalities were reported on Tuesday after a suicide blast at a funeral.
Map of Afghanistan locating Nangarhar province where fatalities were reported on Tuesday after a suicide blast at a funeral. AFP / STAFF

Some 15 people were wounded and more than 100 -- including three foreign nationals -- were rescued, he said.

One of the wounded, Jamila, said she had taken a grandchild to the hospital for some vaccinations.

"We were outside the hospital. I wanted to go inside when they shot me and one of my grandchildren was killed," said Jamila, who only gave one name.

The hospital is in a neighbourhood that is home to Kabul's minority Shiite Hazara community -- a frequent target of hardline Sunni IS militants.

The hospital is supported by the humanitarian organisation Doctors Without Borders (MSF), and a number of foreigners were working there.

"It beggars belief that such a heinous act could be committed when Afghanistan is being ravaged by the COVID-19 pandemic," UN Humanitarian Coordinator Toby Lanzer said.

Map of Afghanistan locating Nangarhar province where fatalities were reported on Tuesday after a suicide blast at a funeral.
Map of Afghanistan locating Nangarhar province where fatalities were reported on Tuesday after a suicide blast at a funeral. AFP / STAFF

About an hour after the attack, a suicide bomber killed at least 24 people at the funeral of a local police commander in eastern Nangarhar province, provincial spokesman Ataullah Khogyani said.

The attacker detonated explosives in the middle of the ceremony.

"We were preparing (to stand in line for the funeral) when I heard a big blast and then saw hundreds of people on the ground," said Zabit Amir, a mourner at the funeral, which others said was attended by thousands.

"I did not even know who was alive or dead there."

The Taliban denied involvement in either attack.

The latest killings raise fresh questions about the fate of a hoped-for peace process that is teetering just as Afghanistan grapples with a public health crisis.

The Taliban have largely refrained from launching major attacks on Afghan cities since February, when they signed a deal with the US meant to pave the way for peace talks with the Kabul government.

The accord will see all US and foreign forces quit Afghanistan over the next year. Thousands of US troops have already gone, with a drawdown to 8,600 expected within months.

Pentagon spokesman Lieutenant Colonel Thomas Campbell said that "this is going to be a windy, bumpy road, but a political agreement is the best way to end the war."

However, he added that "consistent with the agreement, the US military will continue to conduct defensive strikes against the Taliban when they attack" Afghan partners.

Michael Rubin, a resident scholar at the American Enterprise Institute, likened the peace process to a comatose patient with "no one willing to pull the plug but everyone falling all over themselves with hope if they see an eye blink."

But, he added, Ghani has no other choices than to return to the battlefield.

Laurel Miller, director of the International Crisis Group's Asia program, said she still hoped a peace process can play out, but was concerned it might be "dying a death by a thousand cuts".

However another Afghanistan expert, Barnett Rubin, said putting troops on the offensive was a "reasonable response" that does not sabotage the process.

"On the contrary, it may be necessary to save it," he said.

The violence comes just a day after four roadside bombs exploded in a northern district of Kabul, wounding four civilians including a child.

Those bombings were later claimed by IS.

In March, at least 25 people were killed by an IS gunman at a Sikh temple in the Afghan capital.