(Adds quotes from Gomaa in paragraphs 3 and 7, updates sourcing)

CAIRO, Aug 5 (Reuters) - Egypt's former Grand Mufti Ali Gomaa, once one of the country's top religious authorities, survived an assassination attempt on Friday, security sources told Reuters and state television later reported.

Two men on a motorcycle fired guns on Gomaa as he entered a mosque, the sources said. He was unharmed and one of his body guards received a minor injury to the foot. The gunmen immediately fled the scene.

"If Ali Gomaa dies there are millions who will take his place," Gomaa told state television shortly after news of the attempt was made public. "I gave my sermon right after my survival."

Like many of the top religious figures in the Egyptian state, Gomaa is an adherent of a mystical school of Islam known as Sufism whose practices have sometimes set them at odds with more puritanical Muslims, including hardline Islamist groups.

Gomaa is an outspoken critic of Islamist groups, including the Muslim Brotherhood which the military ousted from power in 2013 after mass protests against former President Mohamed Mursi.

He is also close to President Abdel Fattah al-Sisi, who led the military's ouster of Mursi, and campaigned for his election.

"I tell Sisi remember your God and pray to him and walk in his blessing. God will grant you victory. This proves you are on the right path," Gomaa said.

The grand mufti is in charge of issuing religious edicts as well as issuing a non-binding opinion on all capital sentences.

No group claimed the attempt on Gomaa's life.

Egypt is facing an Islamist insurgency led by Islamic State's local branch in North Sinai where hundreds of soldiers and police were killed. There have been attacks in Cairo and other cities as well.

The country's top prosecutor was assassinated by a car bomb in June last year.

(Reporting by Ahmed Mohamed Hassan and Mostafa Hashem; Writing by Ahmed Aboulenein; editing by Ralph Boulton) ((ahmed.aboulenein@thomsonreuters.com; +20 2 2394 8097; Reuters Messaging: ahmed.aboulenein.thomsonreuters.com@reuters.net))