An Egyptian court has rejected as "unconstitutional" a border agreement that would have transferred two Red Sea islands to Saudi Arabia.
The ruling was a rare rebuke of the Egyptian government’s foreign policy by the judiciary, which has been largely supportive of President Abdel-Fattah al-Sissi.
The ruling also could strain ties with Riyadh, which has provided billions of dollars in aid to Egypt in recent years.
The government had zealously defended the April agreement, arguing that it would bring economic benefits to the country. It says the islands have always been part of Saudi Arabia, and were only placed under Egyptian control in 1950 for protection from Israel.
The government said it has appealed the ruling.
The uninhabited islands of Tiran and Sanafir lie along narrow shipping lanes leading north to the port cities of Eilat and Aqaba in Israel and Jordan, respectively.
Israel occupied the two islands in the 1956 Suez War and withdrew the following year. The closure of the strait by Egypt is seen as one of the main causes of the June 1967 Arab-Israeli war, in which Egypt lost the Sinai Peninsula.
The Sinai was returned to Egypt, together with the two islands, under the landmark 1979 peace treaty with Israel.
Under the treaty’s provisions, Egypt is not allowed to station troops on either island.
The court said the reality on the ground shows that Egypt has long exercised full and uncontested sovereignty over the two islands. “To the extent that Egypt sacrificed the blood of its sons in defence of the two islands, that speaks loudly of them being Egyptian territory,” it said in the ruling.
It said surrendering the islands to the Saudis was a “gross violation” of the country’s constitution, citing a clause in the 2014 charter requiring a nationwide referendum on agreements “related to making peace and alliance, and those related to the rights of sovereignty”.
Critics of the border agreement, which was announced during a high-profile visit by King Salman alongside billions of dollars’ worth of new Saudi aid, view it as a sell-off of sovereign territory. Thousands of protesters took to the streets over the islands, in the largest demonstrations since Mr el-Sissi was elected in 2014.
Authorities responded with a wave of arrests of protesters and activists. However, most were later acquitted, released on bail or fined after brief trials.
There was no immediate comment from the Saudi government on the court ruling.
Egypt’s parliament, which is packed with government supporters, has been expected to debate the agreement and vote on whether to endorse it. No date has been set for the discussion, and it was not immediately clear what impact Tuesday’s ruling might have on the parliamentary process.
In a brief verdict met with an eruption of applause and joyful chants, judge Yahya Dakroury ruled that the two islands at the mouth of the Gulf of Aqaba remain under Egyptian sovereignty and banned “any changes on the two islands for the benefit of any foreign country”.
“This is a very important step,” said Khalid Ali, a prominent rights lawyer and former presidential candidate who jointly brought the case against the government with another lawyer. “I appeal to the Egyptian government ... to implement the court’s ruling. This is the land of our ancestors; you must protect it, and those islands are Egyptian and will remain Egyptian forever.”
Mr Ali spoke as about two dozen supporters outside the court chanted "bread, freedom, those islands are Egyptian", a play on the most popular slogan of Egypt's 2011 uprising – "bread, freedom and social justice" – that toppled autocrat Hosni Mubarak.
Billions of dollars of aid from Saudi Arabia, Kuwait and the United Arab Emirates have kept Egypt’s ailing economy afloat in the nearly three years since el-Mr Sissi, as defence minister, led the military’s ouster of the Islamist Mohammed Morsi, Egypt’s first freely elected president.
Mr el-Sissi has acknowledged that the demarcation negotiations were held over several months in secrecy to avoid unwanted media attention and opposition to the deal.
“We did not surrender our rights, but we restored the rights of others,” Mr el-Sissi said in April. “Please, I don’t want anyone to talk about this any more.”