(The story was refiled to corrects paragraph 6 to say .. one week later ..not.. one month later)

An aerial view of the coast of the Red Sea and the two islands of Tiran and Sanafir is pictured through the window of an airplane near Sharm el-Sheikh, Egypt November 1, 2016. REUTERS/Amr Abdallah Dalsh

CAIRO (Reuters) - Egypt’s top court on Saturday dismissed all outstanding legal challenges to a deal transferring two Red Sea islands to Saudi Arabia, a day before a visit by its crown prince.

The plan to cede the islands to Riyadh, an ally which has given billions of dollars in aid to Egypt, was announced in 2016 and became mired in political protest and legal action.

The Supreme Court ruled that no other court had jurisdiction over the matter, blocking two opposing verdicts - one by the Supreme Administrative Court, which was against ceding control of the islands of Tiran and Sanafir, the other by the Court of Urgent Matters, which looked to void that decision.

“The signature of the representative of the Egyptian state on the maritime borders agreement between the governments of Egypt and Saudi Arabia is undoubtedly an act of sovereignty,” the Supreme Court said in a statement, adding that approving the deal was down to Egypt’s legislative body.

Prince Mohamed signed the deal on behalf of the Kingdom before becoming crown prince.

Egypt’s parliament backed the deal in June, and Sisi ratified it one week later.

Opponents say Egypt’s sovereignty over the islands dates back to 1906, before Saudi Arabia was founded.

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

Saudi Arabia has supported Sisi since he toppled President Mohamed Mursi of the Muslim Brotherhood in 2013, and legal wrangling over the Red Sea deal was a source of tension between the two countries.

Opposition to the deal has been a problem for Sisi, sparking the only major street protests since he came to power in 2014 and becoming a rallying point for opposition figures that have been marginalized during his rule.

Sisi stands for re-election this month in a vote he is almost guaranteed to win after all serious challengers dropped out, including a rights lawyer who shot to fame after successfully challenging the islands deal in court.