A gunman opened fire on a church south of Cairo on Friday, killing at least nine people in the latest apparent jihadist attack on the country's Christian minority.
Health ministry spokesman Khaled Megahed told state television that the gunman was shot dead after killing nine people and wounding others, including a police officer.
But the interior ministry said in a statement that the assailant, a wanted jihadist implicated in attacks on police, had been wounded and arrested.
The jihadist had been armed with an assault rifle, 150 bullets and a bomb he intended to set off at the church, the ministry said.
The ministry said he killed two people when he opened fire on a store before heading to the church where he shot dead seven people including an officer.
Mobile phone footage posted on social media appeared to show the bearded gunman wearing a bulky ammunition vest sprawled on a street, barely conscious, as people restrained his arms and then handcuffed him.
Police later cordoned off the crime scene as onlookers crowded around the church, while a forensics team combed the area.
Congealing blood could be seen at a guard post in front of the church.
ATTACKS ON CHRISTIANS
The Islamic State group's affiliate in Egypt has killed dozens of Christians in church bombings and shootings over the past year, and has threatened further attacks against the minority.
Friday's attack came ahead of Christmas for the Copts, who celebrate it on January 7.
Egypt's Coptic Christians make up about 10 per cent of the country's 93 million people, and are the largest religious minority in the region.
IS claimed a suicide bombing of a Cairo church in December 2016 followed by bombings of two churches north of the capital in April.
A month later, IS gunmen shot dead about 30 Christians south of Cairo as they travelled to a monastery.
The jihadists are believed to have also carried out a massacre of Muslim worshippers in Sinai last month, killing more than 300 in an attack on a mosque associated with the mystical Sufi strand of Islam which IS views as heretical.
Egypt imposed a state of emergency following the church attacks and shootings, and President Abdel Fattah al-Sisi demanded the army confront the jihadists with "brutal force" following the mosque massacre.
The presidency said in a statement on Friday's church attack that it would increase the "resolve to continue the path of cleansing the country of terrorism and extremism."
IS has been waging a deadly insurgency based in the Sinai Peninsula bordering Israel and the Gaza Strip that has killed hundreds of policemen and soldiers.
The jihadists have increasingly targeted civilians as attacks on the security forces have become more difficult.
The army has poured in thousands of troops backed with armour and jets in a bid to crush the Sinai-based jihadists, but attacks have continued.
The attack on the church came a day after six Egyptian soldiers were killed in a roadside bombing in the Sinai.
Last week, IS claimed responsibility for firing an anti-tank missile at a helicopter in a North Sinai airport as the defence and interior ministers were visiting.
The attack killed an aide to the defence minister and a helicopter pilot, but both ministers returned to Cairo unscathed.