CAIRO (AP) -- An Egyptian court on Monday ruled against the government's attempt to transfer two Red Sea islands to Saudi Arabia, an embarrassment for President Abdel-Fattah el-Sissi that could deepen tensions with his onetime Gulf patron.
The decision to transfer the uninhabited islands of Tiran and Sanafir, announced alongside a Saudi aid package last year, fueled accusations of a sell-off and sparked the largest protests of el-Sissi's two-and-a-half-year rule.
The deal was signed last April during a visit by Saudi King Salman, who announced billions of dollars in Saudi loans and investment. The government insists the islands always belonged to Saudi Arabia and were merely placed under Egypt's protection in the 1950s.
But the Supreme Administrative Court, in a unanimous verdict, upheld a lower court's ruling that the move was unconstitutional. It said the islands were Egyptian and that the government provided no documents to prove otherwise.
The ruling marks a major setback for el-Sissi, who rode to power on a surge of nationalism after leading the 2013 military overthrow of Mohammed Morsi, an Islamist and Egypt's first freely elected president.
El-Sissi has since presided over a wide-scale crackdown on dissent, banning all unauthorized protests and jailing thousands. But the islands deal has galvanized opposition among many of his former supporters, and hundreds took to the streets last April after it was announced.
Monday's verdict was met with an eruption of cheers from activists and lawyers in the Nile-side Cairo courtroom, with some singing the national anthem and chanting patriotic slogans.
Khaled Ali, a former presidential candidate and the head lawyer contesting the deal, was lifted onto the shoulders of supporters while flashing the V-for-victory sign and chanting: "The land is Egyptian."
"The verdict is a message to el-Sissi: 'Shame, shame on you!'" Azza Suliman, a prominent women's rights activist, said outside the courthouse.
A small number of activists nearby chanted: "Saudi Arabia, take your money back, for tomorrow, the Egyptian people will trample on you." Minor scuffles broke out between police and demonstrators.
"The legitimacy of this authority is on the line," said Malek Adly, one of the top lawyers who contested the agreement.
The government was already under mounting pressure following a series of austerity measures enacted late last year in order to secure $12 billion in loans from the International Monetary Fund.
The decision to slash fuel subsidies and float the local currency has sent the prices of basic goods soaring in Egypt, where nearly a third of population lives below the poverty line.
The government's turn to the IMF came amid souring relations with Saudi Arabia, which along with other Gulf countries provided billions of dollars in aid after Morsi's ouster in 2013.
Egypt and Saudi Arabia are split over Syria, where Cairo views the government as a bulwark against Islamic extremists and Saudi Arabia supports the rebels fighting to topple President Bashar Assad. Saudi commentators have also accused Egypt of doing little to aid the Saudi-led coalition battling Shiite rebels in Yemen.
Saudi Arabia cut off fuel shipments to Egypt in September after Cairo backed a U.N. resolution on Syria that was opposed by the kingdom.
In an apparent attempt to mend ties, the Egyptian government sent the islands deal to parliament for ratification despite the lower court's verdict, but analysts say the damage was done.
"The Saudis didn't want to watch the entire game and went ahead with the penalties," analyst Yasser Abdel-Aziz said.
The government's options are now limited. It can appeal to the Supreme Constitutional Court, arguing that the president has the right to conclude such a deal, or submit the entire agreement to international arbitration.
El-Sissi could also issue a new decree, but that would be subject to judicial review, and lawyers opposed to the transfer have vowed to continue pursuing the case.
Tamer el-Shahawi, an el-Sissi supporter in parliament, said the court ruling would likely prevent parliament from ratifying the deal. "The government has managed this case in a very poor way," he said.