An Egyptian court declared Tuesday that handing control of two islands in the Red Sea to Saudi Arabia is illegal.
The transfer of Tiran and Sanfir was included in April in a maritime border agreement with Saudi Arabia.
The Egyptian government said Saudi Arabia had legal and historic sovereignty over the islands, and it was simply returning the kingdom's own territory to it, but the decision was met with protests and outrage.
Officials said the protests could damage relations between the two countries. The court's ruling can be appealed.
Saudi Arabia gave authority over the islands to Cairo in 1950, saying Egypt was better equipped militarily to secure the Straits of Tiran. In the 1967 war, Israel seized the islands after Egypt announced plans to ban Israeli ships from passing through the straits.
After the 1979 peace deal between Egypt and Israel, the islands were returned to Egyptian control, along with other lands.