When special forces fighters from the self-styled Libyan National Army carried out a raid in the eastern port City of Derna on Monday, they faced a determined target.
Hisham Ali Ashmawi, himself a former special forces soldier in the Egyptian military, is considered the North African nation's most wanted militant.
Already sentenced to death in absentia following a series of attacks on soldiers, police and coptic Christians, Ashmawi wasn't giving up without a fight.
“As the troops stormed the building where the terrorist was residing in, he attempted to detonate a suicide belt but failed,” said a source inside the Karama Operation Room, which coordinates commander Khalifa Haftar’s forces in their fight against Islamist militants in eastern Libya.
Egyptian authorities have requested his rendition, and his detention will bring to an end a brief but prolific career of militancy that took him from the battlefields of Syria to militant mountain hideouts in Syria.
Ashmawi, also known as Abu Omar Al Muhajir, is a former Egyptian special forces officer. He was dishonorably discharged in 2012 however, following a trial for “inciting” his comrades against the military.
Following his expulsion from the forces, he reportedly travelled to Syria in 2013, where he became active in the then Al Qaeda affiliated Jabhat Al Nusra.
He later traveled to Libya as part of a wave of militants who fled there from Syria to expand their network.
Following the overthrow in July 2013 of the short-lived Islamist presidency of Mohammed Morsi in Egypt, an Islamist insurgency arose in the Sinai. Ashmawi returned to his home country sometime after this to work as an explosives expert for the group Ansar Beit Al Maqdis.
In September 2013, the group claimed responsibility for a failed attempted to assassinate the then Minister of Interior Mohamed Ibrahim, an operation which brought Ashmawi to the attention of local security forces.
Ashmawi and his militant comrades inflicted a series of attacks on Egyptian security forces, contributing to a bloody 2014, in which 182 soldiers and police were killed according to independent estimates.
In one attack on a military headquarters in the north Sinai city of Arish in February 2015, the group killed 29 soldiers. Later in the year the group was blamed for the assassination of former Prosecutor General Hisham Barkat.
Ashmawi was also reportedly involved in a dispute over whether his group should pledge allegiance to the old guard of Islamic militancy in the Middle East represented by Al Qaeda, or whether to join ISIS.
After the group joined ISIS, Ashmawi left to join an Al Qaeda affiliate in Libya called the Al Murabiteen group.
In July 2015, a voice note attributed to Ashmawi called for holy war against the government of Egyptian President Abdel Fattah Al Sisi.
He is believed to have lived in Derna for the past four years, according to the source in the Karama Operation room. This suggests he may have posed a less active militant role recently, as Al Murabiteen did not claim any attacks in this time.
His arrest on Monday follows months of fighting around Derna, during which time the LNA has struggled to fully dislodge Islamist cells.
Egypt will likely try him on a range of terrorism charges, according to an Egyptian security source.
The outcome of any trial will have little bearing on his fate however, as he has already been sentenced to death in absentia, alongside a dozen other defendants, for an attack on a military checkpoint in the Farafra depression in Egypt's Western Desert.