He started working in the judicial department and rose to become the deputy Attorney General in 1978 before he was moved down to Constitutional Court at State Council in 2001 as member and became the deputy judge in 2005. He also served as a secretary-general of the Union of Arab Constitutional Courts which was from 2011– 2018. He retired in the judicial board in 2019 and joined the Parliament after serving as the chief of Supreme Constitutional Court in 2019.
He polled 508 votes out of 576 votes of the parliament and the majority of the votes came from the National List for Egypt party. He has been elected into parliament since 2019.
He has published books which have been translated into different languages. When serving as the head of SCC, he issued many rulings in cases up to 227.
Tiran and Sanafir island controversy
He was the judge that approved the maritime border agreement between Egypt and Saudi Arabia.Cairo had agreed on to ceding of the island of Tiran and Sanafir to Saudi Arabia in 2016 and later President Sisi signed the agreement to transfer the ownership of the island. This caused great irritation from many opposition politicians inside and outside Egypt controversy of his election as the speaker. When Tiran and Sanafir island were transferred to Saudi, many citizens protested and objections were made against the decision, but all fell apart after many days of court hearings but was still passed on by the Supreme Constitution Courts which was already headed by Hanafy Gebali but claimed by Hanafy Gebali that it was the government decision.