Secretary of State Mike Pompeo on Tuesday urged the Afghan government and Taliban to cooperate after grisly attacks on a maternity hospital and a funeral dealt a blow to US efforts to end the war.

Pompeo called the twin assaults "appalling" but noted that the Taliban, who signed a February 29 accord with the United States in his presence, denied responsibility.

"The Taliban and the Afghan government should cooperate to bring the perpetrators to justice," Pompeo said in a statement.

"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 Islamic State group, which has jostled with the Taliban for influence, claimed responsibility for the attack on the police officer's funeral in eastern Afghanistan that killed at least 24 people.

The extremist movement made no mention of the raid on the hospital in Kabul that killed 14 people, including nurses and newborns.

An Afghan security officer carries a newborn baby from a hospital after it is attacked in Kabul
An Afghan security officer carries a newborn baby from a hospital after it is attacked in Kabul AFP / STR

President Donald Trump has been eager to end America's longest war and began pulling troops after the Leap Year accord with the Taliban, who agreed to reduce violence and not target Western forces, although they have kept attacking Afghan troops.

Following the latest bloodbath, President Ashraf Ghani ordered security forces to resume offensive operations against the Taliban as well as other insurgents.

The forces of the internationally backed government had been observing a unilateral posture of only reacting defensively to Taliban attacks.

The US military made clear that it would not join the Kabul government and keep observing its truce with the Taliban.

"The US military will continue to conduct defensive strikes against the Taliban when they attack our (Afghan) partners," said Lieutenant Colonel Thomas Campbell, a Pentagon spokesman.

"This is going to be a windy, bumpy road, but a political agreement is the best way to end the war," he said, quoting a recent statement by Defense Secretary Mark Esper.