The Palestinian rivals had set up a unity government of independents in June but it never took hold, with Palestinian president Mahmud Abbas accusing Hamas of running a "parallel" administration as de facto ruler in the Gaza Strip.
Hamas in turn accused Abbas's Palestinian Authority, headquartered in Ramallah, of not paying its 45,000 employees in Gaza.
"Fatah and Hamas have reached a comprehensive agreement for the unity government to return to the Gaza Strip," Jibril Rajoub of Fatah told AFP.
The talks were crucial for internal Palestinian divisions to be set aside and to agree on a unified strategy during talks with Israeli negotiators in October.
Also Read
The October talks, under Egyptian mediation, are aimed at reaching a durable ceasefire after the 50-day war between Israel and Hamas.
The war killed more than 2,140 Palestinians, most of them civilians, and 73 on the Israeli side.
It ended on August 26 when the two sides agreed in Cairo on a ceasefire and to hold future talks on Palestinian demands to end an eight-year blockade of Gaza and exchange prisoners in Israeli jails for the remains of Israeli soldiers killed in Gaza.
The July-August war caused a vast amount of destruction to homes and infrastructure in densely populated Gaza, leaving more than 100,000 Palestinians homeless, according to the United Nations.
"The unity government will supervise the crossings (into Gaza)... To facilitate the reconstruction of the Gaza Strip," Abu Marzuk said.
He said the two factions agreed to creating a mechanism for construction material to pass in to Gaza.
The two movements have also found a "solution .. To the problem of employees," Abu Marzuk said, referring to the Hamas accusations that the Palestinian Authority had not paid Gaza government employees.