About 88 people were injured, 12 of them children, hospital officials said.
Loud explosions and gunfire could be heard throughout the day in the Gaza City neighborhood of Shijaiyeh, a stronghold of the Fatah-allied Hilles clan. Hamas accuses the clan of hiding suspects responsible for a car bombing last week that killed five activists of the Islamic militant group.
Hamas and the largely secular, Western-backed Fatah have waged a violent struggle for control of Gaza for years. But there have been few signs of Fatah resistance since Hamas seized control of the strip in June 2007.
Relations between the factions deteriorated sharply last week after the car bombing that killed Hamas militants in Gaza and each side has been cracking down on political opponents with growing intensity. Hamas in Gaza and Fatah loyalists of Palestinian President Mahmoud Abbas who control the West Bank have carried out mass arrests.
In the West Bank, Abbas' troops enforced a new ban on public assembly and expanded their arrest sweep beyond Hamas. Club-wielding security men arrested and beat dozens of supporters of a non-violent Islamic group.
The Gaza clashes began when Hamas raided Shijaiyeh under heavy morning fog. Security forces stormed several high-rise buildings and rounded up rooftop snipers, gunmen and wounded fighters, said Islam Shahwan, a Hamas police spokesman.
Heavy battles with mortars and machine guns ensued. Three Hamas policemen and a Hilles member were killed, hospital officials said.
It was the deadliest internal Palestinian fighting since November when Hamas police killed seven people in a Fatah-organized memorial rally for the late Yasser Arafat.
Ahmed Hilles, a clan leader and Fatah official, said Hamas police cut off electricity as they launched the raid. He explained why the clan fought back.
"You have to decide: Either be trampled under Hamas' shoes, or stand in dignity," he told The Associated Press by telephone, with gunshots crackling in the background. Hilles fled to Israel later in the day, Israeli military officials confirmed.
By Saturday afternoon, Hamas police had seized control of Shijaiyeh, home to some 100,000 people. They deployed hundreds of police who went house to house in search of weapons and suspects. In all, more than 50 people were arrested, including some who had tried to flee disguised as women, Hamas said.
Senior Hamas official Siyad Siam said those arrested included men allegedly involved in last week's attack. Hamas forces found explosives like those used in the bombing, as well as machine guns and other weapons, Siam told a press conference in Gaza City late Saturday.
"We are sending a message that no one is above the law and that no family is above the law," Siam said. "Gaza will enjoy peace and security."
More than 180 Palestinians who fled the fighting were allowed through a Gaza crossing into Israel, said an Israeli commander in the border area, Col. Ron Ashrov. The transfer began when a group, including injured people and armed men, ran up to the Gaza fence, Ashrov said.
Israeli soldiers were fired upon as they went to open the fence, apparently by Palestinians, Ashrov said. Twenty-two of those who crossed were injured, he said. Some of those who entered were youths, he said.
The unusual Israeli involvement to save Palestinians fleeing infighting was agreed to by Israeli Defense Minister Ehud Barak after Abbas and the Egyptian government requested the Israeli action, military officials said on condition of anonymity since no official announcement was made about the request.
Officials close to Abbas said Israel had agreed to allow only three of those who had fled to enter the West Bank, and the rest would be sent to Egypt.
Four mortar shells fired from Gaza landed in open fields in Israel Saturday causing no injuries, the army said. The mortars underscored the danger that the Palestinian infighting could embroil Israel.
In the West Bank, security forces armed with clubs arrested and beat dozens of supporters of a non-violent Islamic group, the Liberation Party, and broke up their rally in downtown Ramallah. An AP Television News cameraman was prevented by Abbas' security forces from filming the beatings.
The pan-Islamic Liberation Party has sharply criticized the moderate Fatah leadership, but says it espouses non-violent change. In the past, members of the movement were able to march in the West Bank without hindrance.
A senior security official said there is growing fear Hamas is using the Liberation Party as a front in the West Bank.
Since Thursday, dozens of Liberation Party members have been arrested, said its spokesman, Baher Saleh.
Deeb al-Ali, chief of the national security forces in the West Bank, said all political gatherings were banned because of the growing tensions with Hamas.
"We have to stop rallies and marches or anything that leads to mass gatherings," he said.