CAIRO: Gunmen killed eight plainclothes policemen just outside Cairo overnight, the interior ministry said, in an assault claimed by Islamic State.

The four attackers pulled up in a pick-up truck and sprayed a police vehicle using automatic weapons before fleeing, the ministry said on Sunday.

The gunmen wore masks, residents in Helwan, an industrial town south of the capital, told Reuters.

Egypt's government is facing an insurgency that has killed hundreds of soldiers and policemen, mostly in northern Sinai, since mid-2013, when then-army chief Abdel Fattah al-Sisi ousted Islamist President Mohamed Mursi following mass protests.

Islamic State's Egyptian affiliate, which calls itself Sinai Province, mainly operates out of northern Sinai, which borders Israel, the Gaza Strip and the Suez Canal.

Militants have also occasionally targeted security forces and planted bombs in Cairo and other areas.

In an Arabic-language statement, Islamic State said the Helwan attack was part of its Abi Ali Al-Anbari campaign, which has seen the group carry out a series of bombings and other attacks in Iraq.

It was not clear how or why Egypt was linked to the Iraqi campaign. The statement also said the attack was aimed at avenging women in Egyptian jails but gave no details.

Islamic State controls swathes of Iraq and Syria. In 2014, an Egyptian militant group called Ansar Bayt al-Maqdis pledged allegiance to Islamic State and changed its name to Sinai Province.

Al Azhar, a historic centre of Islamic learning in Cairo, condemned what it called a "terrorist attack the likes of which contradict Islamic teachings" and offered in a statement its support for Egypt's security forces.