Two babies and 12 mothers and nurses were killed in a militant attack on a hospital in the Afghan capital Kabul on Tuesday morning.
Another 15 people, including a number of children, were injured in the attack by several gunmen, officials said.
Meanwhile, in the east, a bombing at a funeral killed at least 24 people.
In the wake of the attacks, President Ashraf Ghani said he was ordering the resumption of offensive operations against the Taliban and other groups.
He accused the militants of ignoring repeated calls for a reduction in violence.
The Islamic State (IS) group said it was behind the attack on a police commander's funeral in Nangarhar, in the east of the country. It is still not clear who carried out the attack on the hospital, and the Taliban have denied any involvement.
A maternity ward in the hospital is run by the international medical charity Medicins Sans Frontieres (MSF) and some of those working there are foreigners.
US Secretary of State Mike Pompeo called the attack on the hospital "sheer evil" and an "unconscionable assault". In a statement he urged the Afghan government and the Taliban to co-operate to "bring the perpetrators to justice".
What happened at the hospital?
The attack began at about 10:00 (05:30 GMT), and locals described hearing two blasts then gunfire. One doctor who fled during the assault told the BBC about 140 people were in the hospital when the gunmen attacked.
Another doctor told AFP news agency that "total panic" took hold as the assault unfolded.
Ramazan Ali, a vendor who saw the attack begin, told Reuters news agency: "The attackers were shooting at anyone in this hospital without any reason… It's a government hospital, and a lot of people bring in their women and children for treatment."
Afghan special forces rescued 100 women and children, including three foreigners, an official told the BBC. The attackers, who reportedly had gained access dressed as police officers, were all killed by security personnel after a battle lasting hours.
Images from the scene showed soldiers carrying one newborn baby to safety, swaddled in a blood-stained blanket.
Many foreign staff live in a guesthouse behind the Dasht-e-Barchi Hospital and a doctor who fled the building told the BBC he saw an explosion there too.
In the past, similar attacks in this mostly Shia area of the capital have been attributed to IS. The group's leader in South Asia and the Far East was arrested in Kabul on Tuesday, with two other high profile members, Afghan intelligence said.
In 2017, IS gunmen disguised as medical staff attacked Kabul's main military hospital, prompting widespread shock and anger and raising questions about security. The authorities later confirmed about 50 people had been killed.
But the Taliban also attack hospitals. Last September, 20 people died after a truck packed with explosives was detonated by militants from the group outside a hospital in southern Zabul province.
On TV, Mr Ghani said: "In order to provide security for public places and to thwart attacks and threats from the Taliban and other terrorist groups, I'm ordering Afghan security forces to switch from an active defence mode to an offensive one and to resume their operations against the enemies."
Fragile hope shaken
Even in a country which has seen the worst of the worst, this savage attack on newborn babies and their mothers has shocked, and shaken fragile hope this would be the year Afghanistan would finally start to turn towards peace.
Images of special forces in bulky body armour, carrying infants to safety, will remain long in the memory of those who have repeatedly called for a ceasefire – especially when Afghans are battling another deadly enemy in Covid-19.
Despite Taliban denials that this ghastly attack was their work, President Ghani's denunciation reflects the anger and frustration of many. Some worry that groups like Islamic State, trying to drive an even greater wedge between Taliban and the government, have also killed for now what were slow uncertain steps toward peace talks.
And for those who have never trusted the Taliban's commitment, this latest attack solidifies their resolve to keep fighting.
What happened at the funeral?
According to survivors, thousands of people had gathered for the local police commander's funeral, and the bomb detonated about half-way thRead More – Source