A small but highly dangerous succession of former Egyptian army officers are joining Islamist militant groups, complicating President Abdel Fattah al-Sisi's efforts to counter what he calls an existential threat from extremism.
These men are raising the stakes in an insurgency that has killed hundreds of soldiers and police since the army toppled Islamist President Mohamed Mursi in 2013.
They pose a danger to U.S. ally Egypt with their knowledge of the Arab world's biggest army, provide militants with training and strategic direction, and even carry out suicide bomb attacks against government officials.
Since Mursi was ousted some officers have joined the Ansar Bayt al-Maqdis (ABM) Islamist group and planned and participated in attacks on the army and other facilities, particularly in the Sinai, said Khalil al-Anani, adjunct professor with the School of Advanced International Studies at Johns Hopkins University.
"We can't talk about a mainstream or a large scale defection towards extremism. We are talking about individual cases that could escape and find a safe haven in Sinai. Yet their attacks are fatal and costly."
As former army chief and head of military intelligence, Sisi is well aware of the Islamist threat from within the military.
A militant cell headed by army officers Abboud al-Zomour and Khaled al-Islambouli assassinated President Anwar Sadat in 1981. Years later, former Egyptian army officer Seif al-Adel rose to the top ranks of al Qaeda.
A senior Egyptian military official told Reuters the defections were not a phenomenon. "It is logical and normal that we monitor deviant thinking. Any armed forces must have loyalty and we take all the measures needed against others. The percentage is minimal … you can count them on one hand."
An Egyptian military source said the army has a unit that tracks anyone suspected of harboring radical ideology.
"Yes there are individuals members of the army who we discover possess extremist religious thoughts. But their numbers are very few. Maybe two or three in a class of 2,000."
More than 200 people, including a handful of former army and police officers, are on trial for joining ABM.
The upheaval that followed Hosni Mubarak's overthrow in 2011 allowed the militants to establish a stronghold in the Sinai.
Army special forces officer Hisham Ashmawy is one example of a military man turned jihadist. He never spoke about politics and rarely prayed in public. Then one day he told off his local cleric for reciting the Koran incorrectly.
It was an early clue that Ashmawy would take the radical path that still alarms Egyptian authorities decades after Sadat died in a hail of bullets.
Men like Ashmawy, who is on the run, are especially troubling for Egypt which is struggling to contain a complex web of militants who roam from the Sinai to Libya, another hub for extremists.
Ashmawy's neighbours in Cairo's Nasr City district, home to many army officers, never suspected he would become one of Egypt's most wanted men.
"He seemed totally dedicated to his job in the army," said Sheikh Hamdi, a preacher in a small mosque below Ashmawy's apartment.
An Interior Ministry video that appealed to the public for help showed a clean shaven Ashmawy in his mid 30s with none of the physical traits associated with hardcore militants.
FROM MILITARY MAN TO HOLY WARRIOR
Ashmawy seemed to have a promising career in the military. In 1996, he was chosen for the elite special forces unit known Thunderbolt. But within four years he raised suspicions.
First Ashmawy was transferred to an administrative post and then he faced a military trial and was discharged in 2007 after he was seen discussing religion with other officers and inciting them to reject orders, according to sources in the National Security service who gather evidence on ABM members.
He was also caught handing out jihadist literature to conscripts. As a civilian, he made a living through an import and export business. But jihad was never far from his mind.
Ashmawy met fellow former army officers in that tiny mosque, said the security sources.
He formed a cell within ABM which specialised in teaching killing techniques. With another former military officer, Ashmawy also leads the group's military training committee.
In the spring of 2013, he travelled to Syria, where militants are fighting the government, the sources said.
"This cell is one of the most dangerous terrorist elements and it is suspected of planning the Al-Arish attack," according to a National Security investigation seen by Reuters.
In that operation in October, 33 members of the security forces were killed in one of the bloodiest attacks in years.
"FIRE WITH FIRE"
ABM knows the propaganda value of having former military officers on its side.
In a taped speech before he tried to blow up the former interior minister's convoy, Waleed Badr, a Military Academy graduate, appeared in his army fatigues and laid out the case for waging war on the military.
The video portrays the army as the oppressor of the people with Sisi as the enemy.
"The Egyptian army has declared war on our religion, and killed and detained a lot of Muslims …. why, why, do you shy away from armed confrontation? Logically, you have to confront iron with iron, fire with fire."
Badr showed Islamist tendencies early on. He faced a military trial three times and was discharged in 2005, despite repeated warnings from his father.
His younger brother, Ahmed, said Badr later travelled to Saudi Arabia because he was "indignant about the vast level of corruption here". In 2010 he showed up in Cairo "wearing the traditional flowing robe and sporting a long beard".
Badr returned to Cairo in 2012, encouraged by the election of Muslim Brotherhood leader Mursi, Egypt's first Islamist president, which he saw as "a first step towards achieving an Islamic state in Egypt", said Ahmed.
After the army ousted Mursi following mass protests and mounted a fierce crackdown on Islamists, Badr told his family he was going to Syria to join the Islamist opposition.
That was the last they heard of him — until a knock on the door one day.
"We were surprised with the security forces coming to our house to arrest our father. After that we knew Walid had blown himself up in the interior minister attack," Ahmed said.
Since Sadat's assassination, authorities have mostly jailed or sentenced militants to death. The crackdowns have prevented an Islamist militant takeover, but the threat remains.
An Egyptian lawyer defending some of the over 200 people accused of joining ABM recalled how a judge asked one of the men why he was staring at him.
According to the lawyer, his answer was: "I am studying the details of your face so that I can relay them to people on the outside."