The Hamas-led government agreed Wednesday to withdraw a controversial private militia from public areas of Gaza in an agreement with the rival Fatah movement aimed at halting weeks of bloody infighting.

The black-clad Hamas militia has been at the center of the power struggle.

"They are going to be in places away from the public. They are not going to be visible to people," said government spokesman Ghazi Hamad. Under the arrangement, the militia is to be folded into the official Palestinian police force, he said.

The agreement came after hours of talks mediated by Egyptian diplomats and joined by Prime Minister Ismail Haniyeh, a top Hamas official.

Hamas also agreed to withdraw the 3,000-member force from public view last week. But within days, the gunmen returned to their positions on the streets. After Wednesday's deal was announced, the Hamas force remained in public view.

CountryWatch: Israel

President Mahmoud Abbas, who leads Fatah, has been in a power struggle with Hamas since the Islamic group beat his party in legislative elections in January. The feud has revolved around control of the security forces.

With most security forces loyal to Fatah, the Hamas government deployed its private militia last month. Sixteen people have been killed in fighting between the sides since the Hamas force was activated.

Abbas has said the Hamas force is illegal but said it could be folded into existing security agencies.

"In this meeting, we agreed to remove all things that can lead to tensions in the Palestinians streets," said Abdel Hakim Awad, a Fatah spokesman.