Abbas and Khaled Meshaal, the exiled leader of the Hamas, signed the deal in a palace overlooking the Kaaba, Islam's holiest shrine.
 
Related story
Formation of the new Palestinian cabinet
The deal sets out the principles of the coalition government, including a promise that it will "respect" previous peace deals with Israel, delegates said.
 
Meshaal said the accord "will unify our ranks. There is a commitment and unity. We will preserve this partnership".
 
Gaza celebrations

In Gaza City, celebratory gunfire erupted after the accord was announced.

Your Views
"Palestinians must focus on the end objective and not get sidetracked by destructive actions"
 
Sunny, Ottawa, Canada

Send us your views
"We've been holding our breath. God willing, this is a permanent agreement, not a temporary truce. We hope this will lead to lifting the siege," said Mahmoud Qassam, a fish seller watching the ceremony at his home in Gaza City's Shaati refugee camp, metres away from Haniya's home.

"Gaza has a different day and a different night," said Abu Ali Saleh, 50. "Gaza has not been this happy in years."

Drivers in Gaza City honked horns, sounded sirens and waved either green Hamas or yellow Fatah flags out of car windows after hearing news of the agreement.

Nour Odeh, Al Jazeera's Gaza correspondent, described the mood as one of "euphoria".

"Both parties have come to the realisation that one cannot cancel the other out."

Announcing the deal at the ceremony, Abbas aide Nabil Amr read a letter in which Abbas designated Haniya to draw up the new government according to the formula agreed on in the talks within five weeks.

Abbas said the deal would "satisfy our people ... and bring us to the shores of peace ... This initiative has been crowned with success".

Agreed formula

As part of the deal, a major step towards averting civil war, the Hamas premier will keep his job, the key post of interior minister will go to an independent while Fatah will name a deputy prime mininster.

Palestinians celebrated the agreement on
the streets of Gaza [AFP]
 
Under the initial agreement, a copy of which was obtained by AFP, Hamas would take nine posts in a new government.

Another six would go to Fatah and one each to four other parties in parliament. Along with the interior portfolio, independents would also get foreign affairs and finance.

The document confirmed that Ziad Abu Amr, the former culture minister, had been nominated as foreign minister and Salam Fayyad as finance minister.

A Hamas official, speaking on condition of anonymity, said Abbas "will choose an independent interior minister from among five names that will be submitted to him by Hamas."

Meshaal also said it was vital that any deal reached be respected by world powers.

"The international community must respect our accord, recognise our Palestinian reality and deal with it seriously," he said.

Israeli reaction

Reacting to the agreement, an Israeli government spokeswomen said that any new Palestinian unity government must abide by previous Western demands regarding the Jewish state.

"Israel expects the new Palestinian government to accept and respect all three of the international community's principles - recognition of Israel, acceptance of all former treaties and a clear renunciation of all terror and violence," said Miri Eisin, a spokeswoman in the office of Ehud Olmert, the Israeli prime minister.

Margaret Beckett, the British foreign secretary, welcomed what she described as an "important" agreement between rival Palestinian factions.

"We welcome the ongoing efforts to end the violence and promote intra-Palestinian reconciliation," Beckett said in a statement released by the foreign ministry.

Source: Al Jazeera and agencies