The Egyptian government wanted to agree an accord that would have ceded control of Tiran and Sanafir.
Two leading human rights lawyers challenged the accord, and the court ruled Monday that there was "irrefutable evidence" that the islands' sovereignty belonged to Egypt, according to Reuters news agency.
News of the decision quickly spread on social media with many tweeting their pleasure under the hashtags #Tiran and #Sanafir.
Cairo's plan to transfer the islands came after Saudi Arabia announced investment projects in Egypt worth billions of dollars.
The islands, which sit between the two countries, have a strategic importance as ships pass by on their way to Jordan and Israel.
David Butter, an associate fellow at the Middle East and North Africa program at London-based think-tank Chatham House
described both the history of ownership of the islands and the relationship between the two nations as "complex."
Butter suggested that Egyptian President Abdel-Fattah el-Sisi may have been trying to offer the Saudis something in return for continuing aid.
But he explained that the ruling could still be subject to another court appeal and further debate in the Egyptian parliament where some MPs oppose the accord.
"The issue is not completely closed," he said.
"Whenever Egypt and Saudi Arabia have a meeting then the islands have been there at the top of the agenda.
"There's not a crisis [between them] but relations are chilly at the moment," he said.
The High Administrative Court decision comes amid continuing economic problems for Egypt.
At the end of last year, CNN reported on food and medicine shortages -- and vital industries such as tourism are still struggling in the aftermath of the revolution in 2011.
Egypt's many challenges
Human rights group Amnesty International recently criticized the country
over what it says is the detention of hundreds of people without access to family or a lawyer.
Half of the detained may never resurface, Amnesty said in a report in 2016 which detailed harrowing accounts of torture carried out by state agents.
Terror attacks also continue to afflict Egypt. Bomb attacks on a Coptic church in Cairo
in December left dozens dead, and US intelligence has suggested that ISIS brought down a Russian passenger jet over Egypt's Sinai Peninsula
, killing all 224 people on board in December 15.