(Previous Gaza, updates with agreement in principle, planned Abbas-Haniyeh meeting) By Wafa Amr RAMALLAH, West Bank, Nov 2 (Reuters) - Rival Palestinian factions agreed in principle to form a new government to replace the Hamas-led administration, Palestinian officials said on Thursday. Mustafa Barghouthi, an independent Palestinian lawmaker, said Palestinian President Mahmoud Abbas and Prime Minister Ismail Haniyeh, a senior Hamas leader, were expected to finalise the details in the coming days. "We have agreed on forming a new national unity government made up of qualified people, a government that is capable of lifting the siege and preserving national unity," he told Reuters in Ramallah. A deal to form a unity government between Abbas's Fatah faction and Hamas collapsed several weeks ago, deepening a power struggle and raising fears of civil war between the groups. Some Palestinian sources said an agreement could see the formation of a government of "technocrats" without direct affiliation to either faction. Hamas would still be expected to select the prime minister, even if it meant that Haniyeh gave up his post. One Hamas official said he expected Haniyeh to stay on. "Both Hamas and President Abbas have shown great flexibility and both were positive, a mechanism to choose the prime minister and the ministers was agreed," Barghouthi said. "A mechanism for putting forward the political programme of the government has been agreed whereby it would not be embarrassing for any side." Late on Thursday, Abbas and Haniyeh reached an agreement to hold a meeting in Gaza in the coming days after speaking on the telephone, an official in Haniyeh's office said. Hamas is regarded as a terrorist organisation by Israel, the United States and the European Union, which have called on the group to recognise Israel, renounce violence and accept past peace accords if it wants to be accepted. The two leaders have not met for over a month amid differences over their stance towards Israel. Hamas has struggled to run the government since it came to power in March after winning elections, because of sanctions imposed by the West against its administration. (Additional reporting by Nidal al-Mughrabi in Gaza)