In February, Mahmoud Abbas, the president of the Palestinian Authority and a member of Fatah, called for presidential and legislative elections before September, in a move which was rejected by Hamas at the time.
"The consultations resulted in full understandings over all points of discussions, including setting up an interim agreement with specific tasks and to set a date for election," Egyptian intelligence said in a statement on Wednesday.
The deal, which took many officials by surprise, was thrashed out in Egypt and followed a series of secret meetings.
"The two sides signed initial letters on an agreement. All points of differences have been overcome," Taher Al-Nono, a Hamas government spokesman in Gaza, told the Reuters news agency.
He said that Cairo would shortly invite both sides to a signing ceremony.