Palestinians take part in a protest at the Rafah border crossing between the southern Gaza Strip and Egypt, calling for an end to the blockade of the coastal territory and to allow in more medicine. (IBRAHEEM ABU MUSTAFA/REUTERS)

The rival Palestinian movements Fatah and Hamas initialed an agreement on Wednesday to end a four-year rift that had divided the West Bank and Gaza Strip between separate governments.

Jolted by the upheavals across the Middle East and street protests by Palestinians demanding reconciliation, the two factions announced that they would work together to form a government that would prepare for elections a year from the signature of their accord.

Although the agreement raised the prospect of reuniting the Palestinians, it was likely to strain their relations with Washington and with Israel, both of which consider Hamas a terrorist organization and refuse to deal with it.

At a joint news conference in Cairo, where the agreement was secretly negotiated with Egyptian mediation, Mousa Abu Marzook, head of the Hamas delegation, said that “the changing political realities in the Arab world” had “a very real impact on this agreement.”

In a nod to the recent demonstrations in the West Bank and Gaza Strip, Azzam al-Ahmad, the top Fatah representative, said: “We say to the Palestinian people who took to the streets chanting, ‘The people want an end to the division!’ — what you wanted was realized today.”

The accord comes as the Palestinians work to secure recognition of Palestinian statehood at the United Nations in September amid a continuing impasse in peace efforts. A healing of the rift between Fatah and Hamas was widely seen by many Palestinians as an imperative precondition to any move toward independence and ending Israeli occupation.

The reconciliation agreement provides for the establishment of a government of technocrats that would prepare for parliamentary and presidential elections in a year and work for the reconstruction of the Gaza Strip, officials on both sides said. The accord also calls for elections to the Palestine National Council, the broadest decision-making body of the Palestine Liberation Organization, and the formation of a joint security committee.

After winning parliamentary elections in 2006, Hamas, a militant Islamist movement, became embroiled in a power struggle with the secular nationalist Fatah party. Hamas seized control of the Gaza Strip in June 2007, routing Fatah forces in a brief factional war. Fatah remains dominant in the West Bank, where it is the ruling party in the Palestinian Authority.

Although details of the agreement between the two factions remain to be worked out before a final signature, the prospect of internal Palestinian reconciliation appears certain to complicate efforts to broker a peace accord between Israel and the Palestinians.

Even before the understanding was formally announced, Israeli Prime Minister Binyamin Netanyahu put Palestinian Authority President Mahmoud Abbas on notice that reconciliation with Hamas would doom the peace process.

“The Palestinian Authority must choose between peace with Israel or peace with Hamas,” Netanyahu said in televised remarks. “Peace with both of them is impossible, because Hamas aspires to destroy the state of Israel and says so openly. It fires missiles on our cities. It fires antitank missiles at our children.” Netanyahu was referring to a recent attack on a school bus by militants in Gaza that killed a 16-year-old boy.

“I think that the very idea of reconciliation shows the weakness of the Palestinian Authority and leads one to wonder whether Hamas will take over Judea and Samaria as it has taken over the Gaza Strip,” Netanyahu added, using the biblical names for the West Bank.

In Washington, Tommy Vietor, spokesman for the National Security Council, said the Obama administration was studying the proposed agreement and seeking additional information.

“As we have said before, the United States supports Palestinian reconciliation on terms which promote the cause of peace,” Vietor said. “Hamas, however, is a terrorist organization which targets civilians. To play a constructive role in achieving peace, any Palestinian government must accept the Quartet principles and renounce violence, abide by past agreements, and recognize Israel’s right to exist.”

Abu Marzook, the Hamas leader, said the conditions set by the Quartet, a group of Middle East mediators comprising the United States, Russia, the European Union and the United Nations, were not part of the reconciliation agreement.

Martin Indyk, a former U.S. ambassador to Israel, cautioned that it was too early to judge the significance of an agreement between two factions that rarely have been able to get along. Previous attempts at reconciliation have inevitably fallen apart because the two have widely divergent goals, he said.

As for the impact on peace prospects, “it doesn’t help at all, in the short term,” said Indyk, who served as an assistant secretary of state for Near East affairs in the Clinton administration, “unless by some miracle Fatah persuades Hamas to change its stripes.”

Aaron David Miller, a former U.S. adviser on Arab-Israeli negotiations, said the accord between the two Palestinian camps was prompted in part by concern about a spillover of popular unrest from the “Arab spring” uprisings in neighboring countries. The deal will create problems for Fatah in its relations with the United States, but it will “broaden their popular base,” Miller said.

“Abbas has ensured peace at home but also prospects of serious tensions abroad, with the United States and, of course, Israel,” said Miller, now a public-policy scholar at the Woodrow Wilson Center in Washington.

Special correspondent Sherine Bayoumi in Cairo and staff writer Joby Warrick in Washington contributed to this report.