The Palestinian rival groups of Hamas and Fatah have taken a major step toward forming a national unity government by hammering out a deal on new cabinet ministers.