Updated

Palestinian leader Mahmoud Abbas' ruling Fatah movement narrowly fended off a strong challenge by Hamas (search) to win local elections Friday, but the Islamic militant group captured the three biggest races in the West Bank (search) and the Gaza Strip, establishing itself as a major political force.

The corruption-tainted Fatah (search) won in 45 of 84 communities in the Palestinian territories, according to results obtained by The Associated Press. But Hamas won 23 contests, including all 15 council seats in the West Bank town of Qalqiliya, on the frontier with Israel, as well as majorities in Rafah and Beit Lahiya in Gaza.

The results, which will not be final until Sunday, were disputed by both sides.

The local elections were seen as the final test for Abbas before July's parliamentary elections. Abbas has been seeking to persuade Hamas to give up violence and transform itself into a political party, but he is also concerned that an increasingly powerful hard-line opposition can hinder his peace efforts with Israel.

Hamas is sworn to Israel's destruction and has carried out dozens of homicide bombings in the Jewish state, though it agreed to a temporary cease-fire along with other militant groups in March. The local campaigns, however, focused on clean government rather than the conflict with Israel.

In Gaza City, senior Hamas leader Mahmoud Zahar said polling results showed that "people voted for the Islamic program, the program of resistance, of change and reform."

Fatah officials said they had hoped to do better.

"The results didn't live up to our expectations," said Kadoura Fares, a Fatah legislator and leader of the movement's younger activists, who have been clamoring for reform.

Abbas, who took power after the death of Yasser Arafat, has made some efforts to weed out corruption in the government and the security forces, but many Palestinians remain skeptical. Hamas, by contrast, has set itself up patiently with years of welfare programs for impoverished Palestinians, especially in Gaza.

More than 400,000 Palestinians were eligible to vote. Turnout reached 80 percent in Gaza and 70 percent in the West Bank. Fatah won 56 percent of the votes, while Hamas took 33 percent, with the remainder going to independents and smaller parties.

Fatah and Hamas presented higher totals of the number of races they won, apparently by claiming independent candidates as their own. Fatah demanded a recount in Rafah and the Bureij refugee camp, but did not explain why it suspected irregularities there.

The elections are difficult to interpret, because tribal rivalries and local matters counted at least as much as party affiliations. The most important test comes July 17, when Palestinians vote for a new parliament after 11 years — and Hamas fields candidates for the first time.

Fatah activists have been pushing for a delay in the parliament vote amid growing concern of defeat, though Hamas insists it be held on time.

The results showed Hamas winning all 15 city council seats in Qalqiliya. In Rafah, which sits on the border with Egypt, Hamas had 10 seats compared with five for Fatah. In Beit Lahiya, another Gaza town, Hamas won seven seats compared with six for Fatah. In the West Bank town of Salfit, Fatah won 13 seats compared with two for Hamas.

In a sign of the militants' strength even in areas with large Christian populations, Hamas won five of the seven seats allotted to Muslims in the town of Bethlehem, which has a total of 15 seats.

"We are very honest and work much more than the others," said Khaled Saada, a Hamas candidate for Bethlehem town council, citing schools, clinics and orphanages run by his group.

Fatah suffered decisive losses in two earlier rounds of local voting, and Palestinian pollster Khalil Shikaki said party leaders learned their lessons from that. Fatah "did a good job preparing for this election by unifying itself and making a strong team with effective people," he said.

Many voters were prepared to try Hamas after what they saw as a Fatah failure.

"Who will work for our future, for our children?" asked Maalik Salhab, a 24-year-old biology student who was wearing a green Hamas hat in Bethlehem and voted for the group on Thursday.

"If I see the outside world refusing to help us and then call Hamas terrorists, then I have the right to choose Hamas because they are doing all these things for me."

In the latest challenge to the cease-fire between Israel and the Palestinians, militants fired two rockets into southern Israel, one of which damaged an empty house, late Thursday. They also fired a mortar shell early Friday at a Jewish settlement in Gaza.

With attacks proliferating, Defense Minister Shaul Mofaz signaled that Israel's patience is wearing thin.

"In the case of Qassam rockets, we have to react resolutely, but with moderation," security officials quoted him as saying Thursday.

Also Friday, the army said a military court has convicted an army sergeant for shooting an unarmed Palestinian in the Gaza Strip in late 2003. The unidentified soldier faces up to 20 years in prison.