Cairo (AFP) - Egyptian President Abdel Fattah al-Sisi announced a three-month state of emergency following twin church bombings by the Islamic State group that killed dozens on Palm Sunday, the deadliest attacks on the minority in recent memory.
The attacks in the Nile Delta cities of Tanta and Alexandria followed a Cairo church bombing in December and came weeks before a planned visit by Catholic Pope Francis intended to show support for Egypt's Christian minority.
Sisi declared the "three-month" state of emergency, which he must present to parliament within a week, during a defiant speech warning that the war against the jihadists "will be long and painful".
The first bombing at the Mar Girgis church in Tanta city north of Cairo killed 27 people, the health ministry said.
Emergency services had scrambled to the scene when another blast rocked St Mark's church in Alexandria where Coptic Pope Tawadros II had been leading a Palm Sunday service.
Seventeen people including at least four police officers were killed in that attack, which the interior ministry said was caused by a suicide bomber who blew himself up when prevented from entering the church.
The ministry said Tawadros was unharmed, and a church official said he left before the explosion.
The private CBC Extra channel aired footage of the Alexandria blast, with CCTV showing what appeared to be the church entrance engulfed in flame and flying concrete moments after a guard turned a man away.
Eyewitnesses said a police officer detected the bomber before he blew himself up.
At least 78 people were wounded in Tanta and 40 in Alexandria, the health ministry said.
Egyptian officials denounced the violence as an attempt to sow divisions, and Francis sent his "deep condolences" to Tawadros.
IS claimed two Egyptian suicide bombers carried out both attacks and threatened further attacks in a statement published on social media.
After the bombings, Sisi ordered military deployments to guard "vital and important infrastructure", his office said.
State television reported that the interior minister sacked the provincial head of security and replaced him after the attack.
"I heard the blast and came running. I found people torn up... some people, only half of their bodies remained," Nabil Nader, who lives in front of the Tanta church, said.
At St Mark's in Alexandria, at night the bodies were brought in wooden coffins decorated with golden crosses to the church yard where hundreds of sad and angry Copts gathered and a priest was saying prayers.
A Muslim funeral was also held in El Behira province for one of the four policemen killed in the St Mark's attack.
Worshippers had been celebrating Palm Sunday, one of the holiest days in the Christian calendar, marking Jesus's triumphant entrance to Jerusalem.
Egypt had been ruled under emergency law -- which allows police expanded powers of arrest and surveillance -- for decades before 2012.
- Pope prays for victims -
Pope Francis, who is due in Cairo on April 28-29, offered prayers for the victims.
"Let us pray for the victims of the attack unfortunately carried out today," he said.
"May the Lord convert the heart of those who sow terror, violence and death and also the heart of those who make weapons and trade in them."
Copts, who make up about one tenth of Egypt's population of more than 92 million and who celebrate Easter next weekend, have been targeted by several attacks in recent months.
Jihadists and Islamists accuse Copts of supporting the military overthrow of Islamist president Mohamed Morsi in 2013, which ushered in a deadly crackdown on his supporters.
In December, a suicide bombing claimed by IS killed 29 worshippers in a Cairo church.
The group later released a video threatening Egypt's Christians with more attacks.
A spate of jihadist-linked attacks in the restive Sinai Peninsula, including the murder of a Copt in the city of El Arish, led some Coptic families to flee.
US President Donald Trump led international condemnation of Sunday's attacks.
"So sad to hear of the terrorist attack in Egypt. US strongly condemns. I have great confidence that President Al Sisi will handle situation properly," he tweeted.
UN chief Antonio Guterres expressed the hope that the perpetrators will be swiftly brought to justice after a Security Council statement condemned the bombings as "heinous" and "cowardly".
- String of attacks -
The Cairo-based Al-Azhar, an influential Sunni Muslim authority, said the attacks aimed to "destabilise security and... the unity of Egyptians".
Egypt's Copts have endured successive attacks since Morsi's ouster in July 2013.
More than 40 churches were targeted nationwide in the two weeks after the deadly dispersal by security forces of two pro-Morsi protest camps in Cairo on August 14 that year, Human Rights Watch said.
Sisi, who as then army chief helped remove Morsi, has defended his security forces and accused jihadists of attacking Copts in order to divide the country.
In October 2011, almost 30 people -- mostly Coptic Christians -- were killed outside the state television building in Cairo after the army charged at protesters denouncing the torching of a church in southern Egypt.
A few months earlier, the unclaimed New Year's Day bombing of a Coptic church killed more than 20 people in second city Alexandria.