Islamic State, fighting to redraw the map of the Middle East, has been coaching Egypt's most dangerous militant group, complicating efforts to stabilize the biggest Arab nation.
Confirmation that Islamic Sate, currently the most successful of the region's jihadi groups, is extending its influence to Egypt will sound alarm bells in Cairo, where the authorities are already facing a security challenge from home-grown militants.
A senior commander from the Sinai-based Ansar Bayt al-Maqdis, which has killed hundreds of members of the Egyptian security forces over the last year, said Islamic State has provided instructions on how to operate more effectively.
"They teach us how to carry out operations. We communicate through the internet," the commander, who asked to remain anonymous, told Reuters.
"They don't give us weapons or fighters. But they teach us how to create secret cells, consisting of five people. Only one person has contact with other cells."
Militant groups and the Egyptian state are old foes. Some of al Qaeda's most notorious commanders, including its current leader Ayman al-Zawahri, are Egyptian.
One Egyptian president after another has crushed militant groups but they have always resurfaced.
The success of Islamic State in seizing large parts of Syria and Iraq has raised concerns in Egypt, where authorities are battling Ansar as well as militants who have capitalized on the chaos in post-Gaddafi Libya to set up over the border.
Islamic State became the first jihadi group to defeat an Arab army in a major operation after steamrolling through northern Iraq in June almost unopposed by the Iraqi military.
Militant threat
Unlike al-Qaeda, which specializes in hit and run operations and suicide bombings, Islamic State acts like an army, seizing and holding territory, a new kind of challenge for Western-backed Arab states.
Army offensives have squeezed Ansar, forcing its members to flee to other parts of Egypt, the commander said. But it still poses a security threat.
President Abdel Fattah al-Sisi has expressed concerns about militants over the Libyan frontier. Security officials say these groups are inspired by Islamic State, an offshoot of al Qaeda notorious for beheadings and mass executions, most recently of American journalists James Foley and Steven Sotloff.
Sisi, who as army chief toppled Islamist President Mohamed Mursi last year after mass protests against his rule and then cracked down on his Muslim Brotherhood, has restored some political stability.
But militant groups still present a major challenge. Security officials say thousands of Egyptian militants have joined Islamic State's jihad in Iraq and Syria and authorities are concerned they could return home to fight the government.
That would pile pressure on Egyptian security forces who have failed to end a campaign of bombings and shootings which killed hundreds of soldiers and police since Mursi's fall.
Egyptian security officials say leaders of Islamic State and Ansar have established contacts. Meanwhile, militants based in Libya have also forged ties with Ansar, creating a complex web.
Headless corpses
Ansar recently said it had beheaded four Egyptians, accusing them of providing Israel with intelligence for an air strike that killed three of its fighters.
Four headless corpses were found in the Sinai Peninsula. It was the first time that any decapitations had been made public in Egypt, a strategic U.S. ally which has a peace treaty with Israel and controls the Suez Canal, a key global shipping route.
In a video on Twitter, armed men in black masks stood over the kneeling captives as one of the militants read out a statement. Minutes later, the four men had their heads cut off.
The Ansar commander, who said his group had contacted Islamic State for advice, described the beheadings as a clear message that anyone cooperating with the group's enemies would face a similar fate. "The beheadings had a purpose," he said.
The violence suggested a new level of radicalism in Egypt, where security crackdowns, political violence and street protests have hammered the economy since the "Arab Spring" uprising ousted President Hosni Mubarak in 2011.
"Ansar and Islamic State definitely have ties but there are no Islamic State members in Egypt," said a security official.
"There is definitely coordination between Ansar, the militants in Libya and Islamic State leaders."
The security official said Egyptian authorities have handed airport officials lists of Egyptians who went abroad to wage jihad.
"There are some people who we know are coming back to carry out attacks so we arrest them. The same goes for others who come back to visit their families," he said.
"There is a third type who comes back to recruit. We just watch him until the time is right to move in."
The movement of Ansar militants from the Sinai to towns and cities outside the peninsula could make it more difficult for intelligence agencies to track the group.
"We have trouble working in Sinai. It's easier elsewhere," said the Ansar commander, adding that fighters were benefiting from advice provided by Islamic State.
"They are teaching us how to attack security forces, the element of surprise," he said. "They told us to plant bombs then wait 12 hours so that the man planting the device has enough time to escape from the town he is in."
The commander said bombings not carried out by Ansar suggested new militant groups had appeared in Egypt, adding that there is a flow of militants both ways across the Libyan border.
"There are others operating in Egypt. We don't know anything about them," he said. "We have individuals who went to Libya. We lost contact."
Asked about pressure from Egypt's military, one of the biggest in the world, the commander said security offensives had created new enemies for the state.
"Every time one of us is killed, two or three others join. Usually relatives of those who are killed."