A Palestinian man wears a yellow Fatah and a green Hamas headband as he flashes a V-sign during a rally celebrating the planned signing of a reconciliation agreement between Fatah and Hamas, in Gaza City, Wednesday, May 4, 2011. (Adel Hana/AP)

The Palestinian factions Fatah and Hamas formalized a reconciliation agreement at a ceremony in Cairo on Wednesday, raising hopes of an end to the bitter four-year-old rift that has left Palestinians under rival governments in the West Bank and Gaza Strip.

“We announce . . . to our Palestinian people that we turn forever the black page of division,” said Palestinian Authority President Mahmoud Abbas, who heads Fatah. He promised to soon visit the Hamas-ruled Gaza Strip, where he has not set foot since the militant Islamist group seized power in 2007 after a brief factional war.

The agreement, brokered by Egypt, has drawn warnings from Israel and stirred concern in Washington that it could undermine peace efforts. The United States and Israel consider Hamas — whose charter calls for Israel’s destruction and which has carried out suicide bombings and rocket attacks against it — a terrorist organization.

The ceremony at the headquarters of Egypt’s intelligence agency, which followed an off-camera signing of the accord by delegation heads from both sides, was delayed by a disagreement over whether Hamas leader Khaled Meshal would speak and sit on the podium with Abbas. In the end, Meshal sat with the other delegates in the hall and his remarks were limited.

To avoid live images of possibly awkward scenes, Egyptian television broadcast a delayed and edited video of the proceedings that showed no handshake between the two leaders, who met later.

Still, the signing prompted celebrations in Gaza City, where drivers honked horns and young men who had gathered downtown danced and shouted “Fatah and Hamas, one hand!” and “National unity!” as they waved Palestinian flags and banners of both factions.

“This is a very precious day for us because it unites the two parts of the country,” said Mahmoud Taha, 27, who was at a smaller celebration in Manara Square in Ramallah, the seat of the Palestinian Authority in the West Bank.

In a first sign of change, the Palestinian Authority’s television channel was allowed to broadcast again from the Gaza Strip, a move reciprocated in the West Bank, where Hamas TV resumed its operations.

Israeli Prime Minister Binyamin Netanyahu, visiting London on Wednesday, called the accord “a mortal blow to peace and a big prize for terror.”

“Just three days ago, the terror axis was dealt a heavy blow with the liquidation of bin Laden. Today in Cairo, it was granted a victory,” Netanyahu said.

Under the accord, the two factions will form a transitional government, composed of unaffiliated technocrats, that will prepare for parliamentary and presidential elections within a year and manage the reconstruction of the Gaza Strip.

The agreement also provides for elections to the Palestine National Council, the broadest decision-making body of the Palestine Liberation Organization, and for Hamas’s entry into the PLO.

Seeking to allay concerns that his partnership with Hamas would harm peace efforts, Abbas asserted that the Palestinians “affirm the commitment to signed agreements and the solution of two states along the 1967 borders” between Israel and the West Bank and the Gaza Strip.

“We reaffirm our principled position renouncing violence and emphatically condemning terror in all its forms,” he said.

The Obama administration has said that it would judge the new Palestinian government by its policies and that it would have to recognize Israel, accept previous agreements with it and renounce violence. Those conditions, rejected by Hamas, have been set by the United States, the United Nations, the European Union and Russia, which make up the Mideast mediation group known as the Quartet.

In Washington, State Department spokesman Mark Toner said the administration would wait and see what the accord means in practical terms but warned, “It’s important now that Palestinians ensure implementation of that agreement in a way that advances the prospects of peace rather than undermines them.”

Meshal said the Palestinians were “ready to give an additional chance” to peace efforts though Israel had consistently rejected them. He said Hamas was prepared to work with Fatah to guide both Palestinian diplomacy and “resistance in all its forms.”

He added that Hamas shared the goal of establishing “a Palestinian state, independent and completely sovereign, on the lands of the West Bank and Gaza Strip, with its capital, Jerusalem, without a single settler, without conceding a single inch and without conceding the right of return” of Palestinian refugees to their former homes in Israel.

“We are ready and we have resolved to pay any price to complete the reconciliation and turn the words into reality on the ground,” Meshal said.

Both factions must hammer out the details of sharing power: choosing a government and prime minister, organizing the elections and the vote for the PLO council, and melding rival security forces that fought each other when Hamas seized control of Gaza.

Under the terms of the agreement, the Fatah-dominated Palestinian Authority will continue to handle security in the West Bank, and Hamas will do the same in the Gaza Strip. The two sides are to form a joint security committee that will oversee current operations and chart future steps.

“There will only be one gun for one authority,” Abbas said.

An additional challenge will be ending hostile policies after a rift during which both sides exchanged harsh verbal attacks, shut down each other’s offices and imprisoned their rivals. Releasing the prisoners, an element of the agreement, could prove to be another bone of contention.

The long-awaited accord was prompted by the upheavals sweeping the Arab world and street protests by Palestinians demanding unity, which raised concerns within both factions that the popular discontent could turn against them, too.

In addition, the uprising against the regime in Syria, which hosts the political leadership of Hamas, has left the organization uneasy about its future there and has drawn it to Egypt, which has signaled readiness to pursue closer ties with the Islamist group than existed under now-ousted President Hosni Mubarak.

The accord also comes during an impasse in negotiations with Israel and amid efforts to secure recognition of a Palestinian state at the United Nations in September. With the peace talks at a standstill, analysts say, Abbas was freer to respond to popular pressure and pursue a rapprochement with Hamas. The resulting accord provides him with an effective mandate to represent all Palestinians, not only those in the West Bank.

Special correspondents Sufian Taha in Ramallah and Islam Abdel Kareem in Gaza contributed to this report.