GAZA CITY -- Adel Sweilem was sure Israelis were attacking militants in his neighborhoood when he woke to gunfire yesterday and rushed to the street. Instead, he saw dozens of Hamas fighters in green headbands, who fired AK-47s at a Palestinian police van and then hit it with a rocket-propelled grenade.
Three Hamas gunmen then surrounded the policemen, shouting, ''Spies! Collaborators!" and shot one of them at close range in the leg, said Sweilem, whose account was matched by police and leaders of the rival Fatah political party that dominates the police force.
Early today, leaders of Fatah and Hamas told reporters that they had agreed to end the armed clashes between the groups and that Hamas fighters would withdraw from the streets of northern Gaza Strip. Previous attempts by Egyptian mediators to negotiate a halt in fighting have faltered.
Yesterday's fighting was the latest in a weeklong burst of clashes that Palestinians say have been the worst violence between Fatah and Hamas in years, leaving many Palestinians in Gaza fearful of civil war just when Israel is on the verge of withdrawing its 8,500 settlers from Gaza.
The confrontations began Thursday night when Palestinian police battled militants from Hamas, the hard-line Islamic group, in an effort to stop them from firing rockets into Israeli territory. The fighting has killed three people and opened a bitter public rift between Fatah and Hamas.
Some Gaza residents called on the Palestinian Authority, the Fatah-dominated governing body, to take control of Hamas, by force if necessary -- a demand the Israeli government has repeatedly issued.
''Hamas says the Jews are the sons of pigs and monkeys, but they [Hamas] are the sons of pigs and monkeys," said Abdelkarim abu Daher, standing by the hospital bed of his son Khalil, the police officer who was shot at close range.
The officer's father, a Fatah supporter, blamed Mahmoud Abbas, the Palestinian Authority president and leader of Fatah, for failing to establish his government as the sole power in the Gaza Strip, which is home to 1.3 million Palestinians.
''Abu Mazen should shoot himself," he said, using Abbas's nickname. ''He is not giving orders. He is not a man."
Jamal al-Obeid, the leader of Fatah's office in northern Gaza, where the fighting erupted, also called on the Palestinian Authority to bring Hamas under control. Otherwise, he said, ''We will take the law into our own hands and punish them in our own way."
Nasser abu Samra, a doctor at Al Awda hospital, said he feared fighting would escalate. ''It is the beginning of civil war," he said.
The week of clashes, the worst open gun battles among Palestinians in several years, has laid bare the tensions among rival factions over control of Gaza.
The stakes are high because the planned pullout of Israeli settlers from Gaza next month will place new power, land, and international aid money in the hands of the Palestinian Authority, the official governing body for Palestinians.
Supporters of Hamas say the authority gives jobs only to followers of Fatah, the party of the late leader Yasser Arafat, and charge that it canceled elections scheduled for this month because it feared Hamas's popularity. The authority blames Hamas for refusing an offer to join the government.
The infighting in some ways echoes the battle between the Israeli government and the settlers, who charge that forcing them out of Gaza is an act of betrayal that will endanger Israel.
After the early-morning clashes, a security adviser to Abbas, Jibril Rajoub, said the Palestinian Authority would keep trying to reach a peaceful resolution with Hamas, working with Egyptian negotiators who have been in Gaza for several days to try to calm the situation.
Mohammed Ishtiya, a Cabinet minister in the authority, called the attacks ''isolated events" and ''childish actions" carried out by ''irresponsible people".
But in the Tel al-Zatar neighborhood, where yesterday's fighting broke out, many residents said Hamas is stronger and more popular than the authority.
''The Palestinian Authority wants to be the main power. They don't want to share the cake," said a man whose house was decorated with Hamas posters and who identified himself as Mohammed Abed, 50.
He said the fighting was fueled by competition for the spoils of the Israeli pullout, adding, ''The Palestinian Authority wants to do what Israel has failed to do, to dismantle Hamas."
Obeid, the Fatah official, said the Fatah-dominated authority deserves the spoils because Fatah's armed wing, the Al Aqsa Brigades, carried out most of the attacks on Israel that the militants claim forced the Gaza withdrawal.
''The land is for those who liberate it," he said. ''We don't deny the contributions of others, which is why we asked Hamas to join the government."
The clash, as described by people in the neighborhood, displayed Hamas's power on the street. It began when Hamas supporters in the neighborhood heard that members of the Preventive Security Force, part of the police, were coming to arrest a Hamas member. Dozens of Hamas men flooded the streets and captured four police officers.
Hamas was still holding one of the men yesterday afternoon, said Obeid, as the man's brother stood nearby and shouted, ''If he is not freed, we will fight!" The Hamas gunmen then milled around the nearby Al Awda hospital, where the wounded were taken, until doctors there summoned members of a rival militia with ties to the hospital and demanded that they leave. Later, children played around the burned-out shell of the police van, peeking inside and twirling its engine fan.
One clash began Friday when police fired in the air after Hamas fighters mocked them as collaborators, said Mohammed Hamdan Nahal, 23, a policeman who was wounded in that fight. He said the militants shouted through megaphones, ''Your dead go to hell, our dead go to paradise."
''I started shooting in the air," he said from his hospital bed. ''What else could I do?"
Ibrahim Abu Thuraya, 20, another policeman wounded Friday, said he did not want war with Hamas. ''I'm angry because they shot at me," he said. ''But they are our brothers."
But at the Al-Shifa hospital, where four of yesterday's wounded were taken, Dr. Jumaa Saqqa, the public relations director and a member of Fatah, disagreed, saying, ''The best solution is to stop Hamas by force. I am a surgeon; if I have gangrene in my arm, I cut it off."