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 in 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 the parliament since 2019.
He has published books which have been translated into different languages. When serving as the head of SCC, he had issued many ruling 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 protest and objections were made against the decision but all fall apart after many days of court hearing but was still past on by the Supreme Constitution Courts which already was headed by Hanafy Gebali but claim by Hanafy Gebali that it was the government decision.