Palestinian factions Fatah and Hamas announced on Tuesday that they had agreed on the “mechanisms” for forthcoming elections and to respect their outcome while reiterating their stance about holding elections in the city of Jerusalem.

In a joint statement on the second day of talks between Palestinian factions in Cairo, they said they had agreed a timeline for the polls and “committed to respecting and accepting their results”.

The deal provides for an “electoral court” with exclusive jurisdiction over the electoral process and any cases arising from the polls, the first in 15 years.

The parliamentary and presidential polls are set for May 22 and July 31, respectively.

The Islamist movement Hamas won an unexpected landslide at the last elections in 2006, a victory not recognised by president Mahmud Abbas’s Fatah.

That led to bloody clashes the following year and a split in Palestinian governance.

Fatah has since run the Palestinian Authority in the Israeli-occupied West Bank and Hamas has held power in the Gaza Strip since 2007, the year Israel imposed a devastating blockade on the coastal enclave.

In their statement, the factions said polling “must take place in Jerusalem, the West Bank and Gaza, without exception” and committed to allowing “public liberties and an atmosphere of political freedom” as well as equal access to official media for all electoral lists.

The deal also includes commitments to immediately release all prisoners detained “on factional grounds or in relation to freedom of opinion”, the statement says.

The parliamentary and presidential polls, set for May and July respectively, are the first in 15 years.