The Palestinian prime minister wrested the agreement early on Wednesday from his Hamas movement and rival Fatah to stop violent incidents.
Both sides also agreed to outlaw the carrying of arms.
Ismail Haniya summoned Hamas and Fatah leaders to his Gaza City office for talks that lasted 4 1/2 hours.
Flanked by Fatah activists, Haniya said just after midnight that the two sides had agreed to put a stop to the violent clashes.
He said both sides agreed that "dialogue is the only language to solve our differences".
Ahmed Helas, a Fatah leader, read a joint statement with a pledge to work out problems peacefully and expel any member who uses weapons illegally.
"Anyone who carries arms will be considered outside the law," Helas said.
Hamas and Fatah have been in a power struggle since Hamas won elections in January.
Fourteen Palestinians were injured in factional fighting on Tuesday, the day after similar Fatah-Hamas clashes left three people dead in the southern Gaza Strip.