A gunman clashed with police outside a Coptic church in Cairo on Friday after trying to break through security barriers protecting the site. At least nine people were killed, an official said, in the latest violence targeting Egypt's Christian minority.

Egyptian authorities identified the gunman as 33-year-old Ibrahim Ismail.

A statement by the Interior Ministry said that Ismail had "attempted to attack another church near to the Mar Mina church, but he failed and ended up shooting two people in a shop next to it."

He then proceeded to attack the Mar Mina church, leaving nine dead, "before security forces wounded and arrested him, confiscating his weapon," the ministry statement said.

Ismail is suspected to have links to several past attacks, including one by a group that opened fire on a police bus last year in Cairo. At least eight policemen were killed in the May 2016 attack.

The Islamic State asserted responsibility for Friday's assault.

The spokesman for Egypt's Health Ministry, Khaled Megahed, said eight Coptic Christians and a policeman were killed in the attack, the Associated Press reported.

At least five people were wounded, Megahed said.

The attack began when gunmen on a motorcycle started firing outside the Mar Mina church in the Helwan neighborhood south of central Cairo, while some worshipers were inside. Egypt's state-run Middle East News Agency, citing the Interior Ministry, initially reported that at least two attackers tried to enter the church. The second attacker apparently fled, the agency reported.

A video posted on social media purports to show Ismail roaming a deserted street before being struck by gunfire. A man is seen later sneaking up to him from the back and snatching his weapon. Dozens of people then rush out from hiding to tackle and beat the fallen gunman.

Egypt's Coptic community has come under increasing attack by Islamist militants in recent years, prompting tighter security measures around churches and other sites.

After Friday's bloodshed, Egyptian President Abdel Fatah al-Sissi condemned the assault as "vicious." A statement from Egypt's parliament said the "bullets of terrorists did not differentiate between a Muslim and a Christian, or between a mosque and a church."

In May, gunmen ambushed a bus carrying a group of Coptic Christians to a monastery in the Minya region, about 150 miles south of Cairo, killing at least 30 people.

Brian Murphy in Washington contributed to this report.