"Today we signed an agreement for national unity and we say that the path to completing this journey is national unity," senior Hamas official Musa Abu Marzuk told reporters, according to Chinese state media.
"We are committed to national unity and we call for it," said Abu Marzuk.
The signing concluded three days of reconciliation dialogue between 14 Palestinian groups in the Chinese capital.
Chinese Foreign Minister Wang Yi described the deal as an agreement to rule the Gaza Strip together once the ongoing war ends.