The rival Palestinian movements Fatah and Hamas agreed Wednesday to reconcile and form an interim government ahead of elections, after a four-year feud, in what both sides hailed as a chance to start a fresh page in their national history.

Israel said the accord, which was brokered in secrecy by Egypt, would not secure peace in the Middle East and urged Abbas to carry on shunning the Islamist movement, which has governed the Gaza Strip since 2007 after ousting Fatah in a civil war.

Forging Palestinian unity is regarded as crucial to reviving any prospect for an independent Palestinian state, but Western powers have always refused to deal with Hamas because of its refusal to recognize Israel and renounce violence.

"We have agreed to form a government composed of independent figures that would start preparing for presidential and parliamentary elections," said Azzam al-Ahmad, the head of Fatah's negotiating team in Cairo. "Elections would be held in about eight months from now," he said, adding the Arab League would oversee the implementation of the agreement.

At the news conference in Cairo, where the Fatah and Hamas leaders sat side by side, Ahmad said Palestinians had paid a heavy price for their infighting.

"We are proud that we now possess the national will to end our divisions so we can end the occupation of Palestine ... the last occupation in history," he said.

Hamas' deputy leader, Moussa Abu Marzouk, added: "Our rift gave the occupation a chance. Today we turn a new page."

Hamas won the last Palestinian legislative elections held in 2006 and a new ballot is months overdue. Israel is worried such a vote could hand Hamas control of the West Bank, which is run by Abbas and his more secular supporters.

Prime Minister Benjamin Netanyahu lambasted the reconciliation, declaring in a televised statement: "The Palestinian Authority must choose either peace with Israel or peace with Hamas. There is no possibility for peace with both," Netanyahu said in a televised statement.

The White House said Hamas was "a terrorist organization" and added that any Palestinian government would have to renounce violence. A U.S. official said it would also have to respect past peace deals and recognize Israel's right to exist.

Both Hamas and Fatah, however, dismissed Netanyahu's ultimatum. "Abu Mazen [Palestinian President Mahmoud Abbas] has said we want Hamas, Hamas is part of the Palestinian national fabric," Fatah's Ahmad said.

Hamas spokesman Taher al-Noono also said Israel was "not concerned with Palestinian reconciliation and has been an impediment to it in the past".

Ordinary Palestinians have repeatedly urged their leaders to resolve their deep divisions, but analysts thought differences on core issues such as security were too wide to bridge, with Hamas and the Palestinian Authority running separate forces.

Mahmoud al-Zahar, a senior Hamas leader who participated in the talks, said Wednesday's deal covered five points, including combining security forces and forming a government made up of "nationalist figures".

He said Hamas and Fatah would free respective prisoners.

Implementation of the accord is due to start following an official signing ceremony in Cairo, expected in early May.

Abbas is dependent on Western aid, which he has used to build up state institutions ahead of hoped-for independence.

Peace talks between Israel and Abbas broke down last year and the Palestinian president has been pushing instead to obtain backing in the United Nations this September for an independent nation on all the territory Israel occupied in the 1967 Six-Day War.

Netanyahu has criticized such a unilateral move and is expected to address a joint meeting of the U.S. Congress during a visit to Washington next month where he plans to outline a plan to re-start the frozen negotiations.