The Islamic State group claimed its "soldiers" carried out the attack on the Saint Mina Coptic church in the district of Helwan, just south of Cairo.
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 the assailant, a wanted jihadist implicated in attacks on police, had been wounded and arrested.
The man had been armed with an assault rifle, 150 rounds of ammunition and a bomb he intended to set off at the church, the ministry said.
It added that he had killed two people when he opened fire on a store before heading to the church where he shot dead seven people including the officer.
Cellphone 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 team of forensic experts combed the area.
Congealing blood could be seen at a guard post in front of the church.
IS later claimed responsibility.
In a statement released via its propaganda agency Amaq, it said a group of its "soldiers" had carried out the attack, killing 10 "crusaders" and police officers.
It added that one of its fighters had been killed.
An IS affiliate in Egypt has killed dozens of Christians in church bombings and shootings during 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.
Series of attacks on Christians
Egypt's Coptic Christians make up about 10 percent 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 and 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 after 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 Friday's church attack 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.
Egypt's Gulf allies sent their condolences over Friday's shooting.
Saudi Arabia said it would "stand with Egypt against sinful terrorist acts", while the United Arab Emirates called the attack a "cowardly".
Qatar, at the centre of a long-running dispute with its Gulf neighbors and Egypt, which accuse it of supporting extremist groups, also sent condolences and emphasized its "firm position in rejecting terrorism".