Egypt's President Abdel Fattah al-Sisi on Wednesday ratified a law banning active and former military personnel from running for the presidency or parliament without the army's approval.
The legislative changes come after Egyptians voted overwhelmingly last year in favour of constitutional amendments that will potentially allow Sisi, a former army chief, to stay on until 2030.
The new law is expected to make it almost impossible for military personnel to run in any election, in effect preventing anyone from squaring off against Sisi.
"The Parliament has decided the following law and we have issued it," the official Egyptian gazette said.
"Officers who serve or those whose service has ended in the armed forces aren't allowed to run for the Presidency or Parliamentary or local councils elections without the approval of the Supreme Council of the Armed Forces," it added.
Since it became a modern republic, all but two of Egypt's presidents have hailed from a military background.
The army is highly visible in Egypt's public life, with former top brass currently serving as ministers and heading governorates as well.
Sisi led the army's overthrow of elected president Mohamed Morsi in 2013 following mass protests against the Islamist leader's rule.
Sisi won his first term as president in 2014 and was re-elected in March 2018 with more than 97 percent of the vote, after standing virtually unopposed.
The amended law also prohibits officers from divulging information during their service publicly or joining political parties without the Supreme Council of Armed Forces' permission.
SCAF is a military council comprised of the country's most senior generals. It ruled Egypt following the toppling of long-time autocrat Hosni Mubarak in 2011.
A former chief of staff of the armed forces, Sami Anan, was jailed in January 2018 after contesting the presidential elections against Sisi without the military's explicit approval.
He was released nearly two years later.
A military court jailed another former soldier in December 2017 for six years for announcing his decision to enter the presidential race as a potential candidate in a video he posted on YouTube.