An Egyptian court has upheld an agreement to give control of two islands in the Red Sea to Saudi Arabia, providing a boost for the government.

The appeals court in Cairo upheld on Saturday a verdict by a lower court that annulled a ruling by the administrative court, which had said the agreement to hand over the islands was void, judicial sources said.

Last week, the Egyptian government approved the deal to hand over the islands and sent it to parliament for ratification, despite the legal dispute over the plan.

The territorial deal, announced in April, caused a public uproar among many Egyptians, who said the uninhabited islands of Tiran and Sanafir belonged to their country.

The administrative court had said the agreement violated Egypt’s constitution, which prohibits giving away any part of Egyptian territory to another country.

A more senior tribunal, the higher administrative court, is due to issue a verdict on January 16.

Tiran and Sanafir are in the narrow entrance to the Gulf of Aqaba leading to Jordan and Israel.

Saudi and Egyptian officials say the islands belong to Saudi Arabia and were only under Egyptian control because Riyadh asked Cairo in 1950 to protect them.

Many Egyptians reject the government argument, accusing it of selling part of their homeland.

Lawyers who oppose the handover say Cairo’s sovereignty over the islands dates to a 1906 treaty, before Saudi Arabia was founded.

Saudi Arabia has provided billions of dollars of aid to Egypt, but recently halted fuel shipments.