A top Egyptian court has upheld a ruling halting a plan to transfer two Red Sea islands to Saudi Arabia.
The High Administrative Court rejected an appeal by the government against a lower court's decision to stop it handing over Tiran and Sanafir.
Cheers erupted as the judge delivered the verdict, saying the government had failed to provide evidence that the islands were originally Saudi.
The transfer deal, signed last April, sparked rare protests in Egypt.
Tiran and Sanafir are located at the mouth of the Gulf of Aqaba. They are uninhabited apart from Egyptian troops and multi-national peacekeepers.
President Abdul Fattah al-Sisi said the islands had always belonged to Saudi Arabia and that Riyadh had asked Egypt to station troops there in 1950 to protect them.
But Mr Sisi was accused of violating the constitution and "selling" the islands in return for a multi-billion dollar aid package announced during a visit to Cairo by King Salman.
Saudi Arabia has backed Mr Sisi financially since he led the military's overthrow of his Islamist predecessor, Mohammed Morsi, in 2013.
Uproar at the maritime border demarcation accord prompted protests across Egypt at which hundreds people were detained, according to human rights activists.
A group of lawyers, including former presidential candidate Khaled Ali, also challenged the agreement at an administrative court.
Mr Ali argued that a 1906 maritime treaty between Egypt and the Ottoman Empire stated that the islands were Egyptian. The kingdom of Saudi Arabia was not established until 1932.
In June, the court nullified the border accord, ruling that Egyptian sovereignty over the islands held and could not be amended in favour of another state.
The government subsequently lodged an appeal with the High Administrative Court. It is part of the State Council, a judicial body that gives legal advice to the government, drafts legislation, and exercises jurisdiction over administrative cases.
On Monday, the High Administrative Court said it was the "unanimous" decision of its judges that Tiran and Sanafir were sovereign Egyptian territories.
Lawyers and activists celebrated and chanted: "These islands are Egyptian."
"This verdict is a victory for Egypt," Mr Ali, who was carried out of the court building on the shoulders of his supporters, told Reuters news agency.
There was no immediate response from the Egyptian or Saudi governments.
Why the Red Sea islands matter
- Sanafir and Tiran are islands that lie about 4km (2 nautical miles) apart in the Red Sea. Tiran sits at the mouth of the Gulf of Aqaba, on a strategically important stretch of water called the Strait of Tiran, used by Israel to access the Red Sea
- The islands are uninhabited, apart from Egyptian military personnel and multi-national peacekeepers, since 1982
- Egyptian troops have been stationed on the islands since 1950 at the request of Saudi Arabia
- Israel captured the islands in 1956 and 1967, subsequently returning them to Egypt both times
- Egyptian President Abdul Fattah al-Sisi was criticised for "selling" Egyptian territory after deciding in April 2016 to hand the islands to Saudi Arabia