Palestinian factions Hamas and Fatah have signed a declaration in Beijing on ending a years-long rift, Chinese state media said.

The two rival Palestinian groups met Chinese foreign minister Wang Yi on Tuesday, concluding talks that started on Sunday.

It comes after the Israeli military ordered the evacuation of part of an area in the Gaza Strip it has designated a humanitarian zone and as the Gaza Health Ministry said the death toll from the conflict has passed 39,000.

Palestinians displaced by the Israeli air and ground offensive on the Gaza Strip flee from parts of Khan Younis (Abdel Kareem Hana/AP)

The military said it is planning to begin an operation against Hamas militants who have embedded themselves in the area and used it to launch rockets towards Israel.

Hamas and Fatah signed the Beijing Declaration on “ending division and strengthening Palestinian unity”, according to state broadcaster CCTV.

While the groups have said they would work together many times before and failed, the signing of the declaration coincides with US Secretary of State Antony Blinken saying that a ceasefire between Israel and Hamas appears within sight.

Hamas routed Fatah forces in Gaza in a violent takeover of the territory in 2007.

Unity efforts have been wrecked by the factions’ own bitter rivalry over power and the West’s refusal to accept any government that includes Hamas unless it expressly recognises Israel.