The Hamas-led government agreed on Wednesday to withdraw a controversial private militia from the public areas in the Gaza Strip, in an agreement with the rival Fatah movement aimed at halting weeks of bloody infighting. The agreement came after hours of talks mediated by Egyptian diplomats. 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. Hours before the meeting, however, a senior police official escaped an apparent assassination attempt when a bomb went off prematurely, injuring an assailant. The attempt to halt the violence came amid a deeper disagreement over an ultimatum by Palestinian Authority Chairman Mahmoud Abbas for Hamas to accept the 1967 borderline or face a referendum on the idea. Abbas has given Hamas until the weekend to respond. In the latest violence, a commander in the Fatah-dominated police force in northern Gaza said a group of gunmen tried to detonate a bomb near his house early Wednesday. "Some gunmen set up this device near the entrance to my house. While they were doing this, it went off and one of the gunmen was injured in his hand," said the commander, Omar Khadoura. The incident followed a grenade attack on a pro-Fatah security headquarters in Gaza on Tuesday that wounded three maintenance workers. Fatah blamed Hamas for both attacks. Participants issued a joint statement pledging to reduce tensions and continue talks. "Instructions have been given to the members of both movements to avoid tension and not to react to any incitement in the streets without getting back to their leaders," the statement said. The talks did not discuss Abbas' referendum plan. Backing away from open confrontation, Abbas on Tuesday put off his ultimatum for Hamas to accept a document that implies recognition of Israel or face the voters. Hamas welcomed the offer to continue talks, but said it will not cave in to deadlines. It has demanded changes in the language and called for more time to discuss it. "I get a sense there is a positive attitude in the national dialogue. But it still needs more time," Prime Minister Ismail Haniyeh, a top Hamas leader, said Wednesday.