A gunman opened fire on a church south of Cairo on Friday, killing at least nine people before policemen shot him dead, officials and state media said.

Health ministry spokesman Khaled Megahed told state television that the gunman who was shot dead had killed nine people and wounded others, including a police officer.

The gunman had tried to storm the building when police shot him dead, police officials said.

State television reported that a second assailant who escaped had been arrested.

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 forensics team combed the area.

Congealing blood could be seen at a guard post in front of the church.

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.

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 had 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 quell the jihadists with "brutal force" following the mosque massacre.

The group 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.

They 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 antitank 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.