Egypt's parliament has given its approval to a controversial plan to transfer sovereignty of two largely uninhabited islands to Saudi Arabia.

The deal, to hand over the Red Sea islands of Tiran and Sanafir, was agreed during a visit to Egypt by Saudi King Salman in April 2016.It sparked rare protests in Egypt, with the president accused of "selling" the islands in return for Saudi aid.

The deal has been subject to challenges in court over the past year.

But parliament has insisted the issue lies in its jurisdiction. Final approval is now needed from President Abdul Fattah al-Sisi.Protesters gathered outside the press union in Cairo as news of parliament's approval became known. Several people, including some journalists, were detained.

Mr Sisi said the islands had always belonged to Saudi Arabia and that the Saudis had asked Egypt to station troops there in 1950 to protect them.

A court ruled in January that the government had failed to provide evidence that the islands were originally Saudi, although this ruling was overturned by another court a few months later.

Opponents accuse Mr Sisi of violating the constitution and handing over the islands to please Saudi Arabia which has backed him financially since he led the military's overthrow of his elected Islamist predecessor, Mohamed Morsi, in 2013.

Sanafir and Tiran are islands that lie about 4km (2 nautical miles) apart in the Red Sea

Tiran sits at the mouth of the Gulf of Aqaba, on a strategically important stretch of water called the Strait of Tiran, used by Israel to access the Red Sea

The islands are uninhabited, apart from Egyptian military personnel and multinational peacekeepers

Egyptian troops have been stationed on the islands since 1950 at the request of Saudi Arabia

Israel captured the islands in 1956 and 1967, subsequently returning them to Egypt both times

Egyptian President Abdul Fattah al-Sisi was criticised for "selling" Egyptian territory after deciding in April 2016 to hand the islands to Saudi Arabia.