A desire for unity has been one goal that ordinary Palestinians in both areas have consistently said they sought. Until now it has proved elusive and leaders of the two factions have spoken of each other in vicious terms and jailed each other’s activists.

But with the Palestinians seeking international recognition of statehood at the United Nations by September, Mr. Abbas has repeatedly said that unity must be restored for a credible case to be made. Other recent developments also played a role.

As Mr. Ahmad said after the news conference in Cairo: “The changes in the Arab region and the political upheaval contributed to reducing the pressure on the Palestinian factions, and by pressure I mean the negative kind of pressure.” He said that he was referring to “the changing rules of the game in the region.”

Mkhaimar Abusada, a professor of political science at Al-Azhar University in Gaza, said that the Palestinian Authority’s failure to reach an agreement with Israel and the anger following an American veto of a United Nations Security Council resolution against Israeli settlement construction in February encouraged Fatah to come to an agreement with Hamas. The Islamic group, he said, was motivated to get closer to Fatah by regional changes, especially the protests in Syria, where Hamas’s politburo is based. If President Bashar al-Assad of Syria were to fall, Hamas might no longer be able to use Syria as a base or enjoy the protection, money and arms the country has extended.

“We have ended a painful period in the history of the Palestinian people where Palestinian division had prevailed,” Moussa Abu Marzouk, a representative of Hamas who negotiated the deal, said at the Cairo news conference. “We gave the occupation a great opportunity to expand the settlements because of this division. Today we turn this page and open a new page.”

When he spoke at the news conference, Mr. Ahmad of Fatah recalled the chants of young Palestinian demonstrators mimicking the Tunisian and Egyptian chants: “The people want to bring down the regime.”

“To all the Palestinian youth who went out saying, ‘The people want to end the division’ and ‘The people want to end the occupation,’ we say what you demanded was achieved today,” he said, adding that the period of division had taught both sides “a hard lesson in confronting the occupation.”