Egypt's former leading Muslim cleric, Ali Gomaa, has escaped unharmed from an apparent assassination attempt in Cairo, he told state television on Friday afternoon.
Gomaa told the television channel that four men had shot at him while he was approaching a mosque in 6 October city on the outskirts of Cairo on Friday afternoon, where he was scheduled to lead Friday prayers.
The four gunmen were hiding in a garden and opened fire on the cleric while he was about to enter the mosque.
"I took shelter behind the mosque's wall," he said.
The interior ministry said in a statement that the force guarding the Muslim cleric exchanged fire with the assailants, who subsequently fled the scene.
Gomaa said he insisted on delivering his Friday sermon and led the prayers despite the attack.
"This is a message to (the terrorists) that I will never waver in my war against them," he said.
Gomaa said later on Friday that the attack came in response to the army's killing on Thursday of the chief of the Egyptian affiliate of the Islamic State group, Ansar Beit Al-Maqdis.
The group is spearheading an Islamist insurgency in the northern part of the Sinai peninsula.
The privately-owned CBC Extra channel later aired footage showing armed guards escorting Gomaa out of the mosque following the shooting.
Egypt's Al-Azhar, the traditional seat of Sunni Islamic learning, commented on the incident on Friday afternoon, describing it as a "villainous, terrorist" attack that will not succeed in intimidating the "devoted" Muslim scholars.
Gomaa served as the country's grand mufti, the authority responsible for giving Islamic edicts, for almost a decade until 2013.
Gomaa is known for his controversial Islamic edicts, which he has continued to issue after leaving office through a TV show, on air several times a week, during which he answers religious questions.
He has said that obeying President Abdel-Fattah El-Sisi is part of obediance to the Prophet Muhammed.
Gomaa, an outspoken critic of the Islamist opposition, has also suggested that the now-banned Muslim Brotherhood group are non-Muslims and said the country's police and army should carry arms against them.
One of his personal bodyguards was slightly injured in the foot during the attack, state TV reported.