CAIRO (Reuters) - Egypt’s parliament on Wednesday backed plans to hand over two uninhabited Red Sea islands to Saudi Arabia under an agreement that has attracted widespread public criticism.

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. Picture taken November 1, 2016. REUTERS/Amr Abdallah Dalsh

House of Representatives Speaker Ali Abdelaal said the required majority of lawmakers had voted for the agreement, which the government signed last year, despite a court striking it down in March.

“I announce the House’s final approval of the maritime demarcation agreement with the Kingdom of Saudi Arabia signed on April 8, 2016,” Abdelaal said before adjourning the session.

The treaty must now be ratified by President Abdel Fattah al-Sisi, which is a formality.

The vote came very swiftly. The House Committee on Defence and National Security unanimously backed the plan earlier on Wednesday and referred it to the House for a final vote.

A majority approved it less than four hours later. Those opposed to the measure stood up in protest and chanted “Egyptian, Egyptian” in reference to the islands.

“Today is a terrible day for the Egyptian people, one in which the nation has lost part of its land,” said lawmaker Haitham al-Hariri.

Several legislators opposed to the deal threatened to hold an open-ended sit-in. Some said they were considering resigning in protest.

Sisi’s government last year announced the maritime demarcation agreement with Saudi Arabia, which has given billions of dollars of aid to Egypt, ceding control of the islands of Tiran and Sanafir.

The plan triggered street protests last year from many Egyptians, who say their country’s sovereignty over the islands dates back to a treaty from 1906, before Saudi Arabia was founded.

Dozens of protesters gathered in downtown Cairo outside the press union on Tuesday evening. Eight were arrested, including three journalists, and are being held for 24 hours to be questioned on accusations of illegally protesting and insulting the president, according to state news agency MENA.

The Egyptian and Saudi governments say the islands are Saudi but have been subject to Egyptian protection since 1950 at the request of Saudi Arabia.

JURISDICTION SPAT

The treaty has been referred to the courts, irritating Riyadh and raising tensions between two Arab allies.

Egypt’s highest administrative court blocked the deal but parliament insisted the matter was constitutionally within its domain.

Parliamentary leaders and government lawyers say the House of Representatives is the only entity allowed to rule on matters of sovereignty while the Supreme Administrative Court insists it is within its jurisdiction to scrap the deal.

The Supreme Constitutional Court will rule on who has jurisdiction but has not set a date or even started discussing the issue. It was not immediately clear what the legal situation of the treaty was following Wednesday’s vote.

A government report advising parliament on the terms of the agreement said Egypt would keep administrative control over the islands and Egyptians would not need visas to visit them if they were transferred to Saudi Arabia.

Opposition groups accuse Sisi of handing over the islands to please his Saudi backers and in return for continued aid.

Saudi Arabia was Sisi’s biggest international supporter when he led the military in ousting an elected but unpopular Islamist president in 2013 following mass protests.