The new Hamas security force clashed with Fatah fighters in Gaza late Thursday, culminating a day of tense standoffs as the rivals competed for control of the Palestinian territory.

Two Palestinian policemen were shot in the legs during the exchange of fire near the parliament building and police headquarters, officials said. A Hamas gunman was also wounded, the group said. His condition was not known.

The Palestinian police, who are mostly Palestinian President Mahmoud Abbas loyalists, were instructed by radio to respond with force to any attacks by Hamas forces.

An Associated Press reporter on the scene said Hamas forces closed off the streets leading to police headquarters, the stronghold of the Fatah loyalists, and sporadic exchanges of fire could be heard every few minutes, half an hour after the clash began. Police were running to their posts.

Khaled Abu Hilal, spokesman of the Hamas-controlled Interior Ministry, said unknown gunmen opened fire on the police headquarters from a moving car. Police apparently thought the Hamas forces nearby were responsible and fired at them.

Abu Hilal said all sides were working to calm the situation, and Egyptian diplomats were also involved.

Earlier, Abbas ordered the Islamic militants to remove the militia from the streets, but Hamas refused. Officials in Abbas' office said he would not use force, fearing a civil war. Abbas is the leader of Fatah.

During the day, about 2,000 Fatah supporters in military formation, many bare-chested, double-timed through a main street of Gaza City, shouting, "Jerusalem, the president, the homeland," clapping and whistling as they passed Hamas gunmen.

Similar scenes played out up and down the seaside territory. Competing forces patrolled, studiously ignoring each other. In the southern city of Khan Younis, a Hamas leader accused Fatah gunmen of firing at his house and threatened reprisals. No one was hurt.

The power struggle began after Hamas was the surprise winner of a January parliamentary election, forming a government several weeks later to replace Fatah, the movement that ruled Palestinian politics for decades under the firm hand of Yasser Arafat, who died in 2004.

Abbas, elected to replace Arafat in January 2005, has another three years to serve as president, regardless of who controls the Cabinet. He has been systematically trying to reduce Hamas power, while trying to persuade the world to deal with him directly, including funneling vitally needed foreign aid through his office to bypass the Hamas-led government, which is facing a Western boycott.

Hamas is not making direct threats against Abbas. Its tactic has been to go about its business and ignore the demands of the 70-year-old Fatah leader, who has yet to cut an impressive figure as Arafat's successor.

Hamas called Abbas' bluff on Thursday, flatly refusing to follow his order to take its new 3,000-man force off the streets. Abbas aide Tayeb Abdel Rahim said the president would deal with this as a legal matter, ruling out an armed confrontation.

Interior Minister Said Siyam of Hamas deployed the unit Wednesday, in defiance of Abbas' orders to disband it. Hamas militants armed with assault rifles, grenades and anti-tank missiles took up positions in the streets, and in one case put down a peaceful protest by college graduates seeking teaching jobs.

Fatah responded with demonstrations in Gaza City and stepped-up patrols throughout the territory.

Gen. Suleiman Hilles, commander of Fatah-dominated Palestinian security forces in the West Bank and Gaza, said the forces were deployed to send a message that "the Palestinian police is the only side that can maintain law and order."

However, the lines were not clearly drawn, since some of the police officers also back Hamas. Several hundred police officers met Thursday with Palestinian Prime Minister Ismail Haniyeh of Hamas and professed their loyalty to the government. Haniyeh told the officers that the new unit of militants was formed legally and that it would work alongside the security forces.

Even before the January election put Hamas in power, Abbas avoided confronting Hamas and other militant groups, hoping to tame them through negotiations. Now he clearly fears an all-out civil war, though activists on all sides insist their weapons should be directed against Israel, not each other.

The unprecedented Hamas-Fatah friction, including deadly drive-by ambushes against two Hamas gunmen in Gaza earlier in the week, came alongside new efforts to explore a possible revival of Mideast peace contacts.

Abbas was to hold talks Sunday with Israeli Foreign Minister Tzipi Livni, the first high-level meeting since Hamas came to power, Palestinian official Saeb Erekat said. Israel has said it would not resume negotiations, even with Abbas, unless Hamas softens its violently anti-Israel views.

Without a Hamas about-face by the end of the year, Israel plans to begin drawing its final borders with the Palestinians under Israeli Prime Minister Ehud Olmert's "consolidation" plan.

Olmert was to make his first trip to Washington as prime minister next week and was expected to come under U.S. pressure to try to negotiate a deal with Abbas, rather than move unilaterally.

Vice Premier Shimon Peres told European diplomats on Thursday that Israel, too, prefers a negotiated settlement and would take unilateral steps "only if we are unable (to negotiate) because of lack of a partner," according to a statement from his office.