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.
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.
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.