Chinese Foreign Minister Wang Yi, who hosted senior Hamas official Musa Abu Marzuk, Fatah envoy Mahmud al-Aloul and emissaries from 12 other Palestinian groups, said they had agreed to set up an "interim national reconciliation government" to govern post-war Gaza.
"Today we sign an agreement for national unity and we say that the path to completing this journey is national unity. We are committed to national unity and we call for it," Abu Marzuk said after meeting Wang and the other envoys.
The announcement comes more than nine months into a war sparked by Hamas's October attack on southern Israel, which resulted in the deaths of 1,197 people, mostly civilians, according to an AFP tally based on Israeli figures.
The militants also seized 251 hostages, 116 of whom are still in Gaza, including 44 the Israeli military says are dead.
Israel's retaliatory military campaign in Gaza has killed more than 39,000 people, also mostly civilians, according to data from the health ministry in Hamas-run Gaza.
The relentless fighting has plunged Gaza into a severe humanitarian crisis.
China has sought to play a mediator role in the conflict, which has been rendered even more complex due to the intense rivalry between Hamas, which rules the Gaza Strip, and Fatah, which partially governs the occupied West Bank.
Israel has vowed to keep fighting until it destroys Hamas, and world powers including key Israeli backer the United States have scrambled to imagine scenarios for the governance of Gaza once the war ends.
As Tuesday's meeting wrapped up in Beijing, Wang said the groups had committed to "reconciliation".
"The most prominent highlight is the agreement to form an interim national reconciliation government around the governance of post-war Gaza," Wang said following the signing of the "Beijing declaration" by the factions in the Chinese capital.
"Reconciliation is an internal matter for the Palestinian factions, but at the same time, it cannot be achieved without the support of the international community," Wang said.
'Peace and stability'
China, he added, was keen to "play a constructive role in safeguarding peace and stability in the Middle East".
Beijing, Wang said, called for a "comprehensive, lasting and sustainable ceasefire", as well as efforts to promote Palestinian self-governance and full recognition of a Palestinian state at the UN.
Hamas and Fatah have been bitter rivals since Hamas fighters ejected Fatah from the Gaza Strip after deadly clashes that followed Hamas's resounding victory in a 2006 election.
Fatah controls the Palestinian Authority, which has partial administrative control in the Israeli-occupied West Bank.
Several reconciliation bids have failed, but calls have grown since the Hamas October attack and nine-month war in Gaza, with violence also soaring in the West Bank where Fatah is based.
China hosted Fatah and Hamas in April but a meeting scheduled for June was postponed.
China has historically been sympathetic to the Palestinian cause and supportive of a two-state solution to the Israeli-Palestinian conflict.