Hamas crushed an al-Qaida-inspired group in an hours-long standoff that came to a fiery end when a large explosion killed the radical Muslim group's leader inside his Gaza home on Saturday.

The fighting was sparked by a rebellious sermon by the group's leader, and his dramatic death put an end to the greatest internal challenge to Hamas' rule since it took control of Gaza two years ago.

In all, the fighting claimed 24 lives - including that of a senior Hamas official who Israel says masterminded the abduction of Israel Defense Forces soldier Gilad Shalit. It was the highest death toll in the territory since the Israel-Hamas war earlier this year.

The crackdown targeted Jund Ansar Allah, or the "Soldiers of the Companions of God," one of a number of small, shadowy groups that are even more radical than Hamas. The decisive confrontation, in which 95 group members were arrested, solidified Hamas' iron rule in Gaza.

The radical groups have sought to expand the Palestinians' battle beyond Israel to include the Western World as well. And in Gaza they have tried to enforce a strict version of Islamic law to which Hamas has not agreed.

They have also attacked Internet cafes and wedding parties over behavior they consider improper.

The crackdown highlights Hamas' desire to limit its struggle to the Palestinian cause and to distance itself from militants espousing al-Qaida's ideology, though the United States, Israel and others consider Hamas a terrorist organization.

The fighting broke out late Friday when Hamas security men surrounded a mosque in the southern Gaza town of Rafah on the Egyptian border where about 100 members of Jund Ansar Allah were holed up.

Their leader, Abdel-Latif Moussa, provoked Hamas by declaring Gaza an Islamic emirate during a Friday prayer sermon and warning its leaders against invading his mosque.

The Hamas forces raided the mosque, setting off a fierce gunbattle. Flares lit up the sky and the sound of machine gun fire echoed throughout the night.

Moussa escaped with some bodyguards to his home where another standoff ensued.

Early Saturday, an explosion went off as Hamas was trying to convince Moussa to surrender, said Ihab Ghussein, a Hamas Interior Ministry spokesman.

"The so-called Moussa has committed suicide...killing a mediator who had been sent to him to persuade him and his followers to hand themselves over to the government," Ghussein told The Associated Press.

It is unclear whether Moussa detonated the explosives vest he was wearing, or whether it was one of his bodyguards.

Dr. Moaiya Hassanain of the Palestinian Health Ministry in Gaza said 24 people were killed, including six Hamas police officers and an 11-year-old girl. At least 150 people were wounded, he said.

Hamas confirmed one of its casualties was a high-ranking commander, Abu Jibril Shimali, whom Israel said orchestrated the capture three years ago of Shalit, who is still being held by Hamas.

'We declare the birth of the Islamic Emirate'

Jund Ansar Allah seeks to enforce an even stricter version of Islamic law than that advocated by Hamas.

The clashes came as Jund Ansar radicals defied the Hamas rulers of Gaza on Friday by declaring an "Islamic emirate" in the territory.

Speaking before weekly prayers, Abdel-Latif Moussa - known to followers by the al-Qaida-style nom de guerre Abu al-Nour al-Maqdessi - announced the start of theocratic rule in the Palestinian territories, starting at Rafah, and vowed to implement Islamic laws.

"We declare the birth of the Islamic Emirate," declared Moussa, a heavily-bearded, middle-aged cleric in a red robe who was guarded by four black-clad, masked men with assault rifles. One wore what appeared to be an explosive suicide belt.

An audience of several hundred men filled the mosque with cheers and shouts. Al-Qaida uses the historical term "emirate" to mean clerical rule across the Islamic world.

Ismail Haniyeh, who heads Gaza's Hamas government, denied in his Friday sermon that there were any non-Palestinian gunmen in the territory, as alleged by Israel which charges that veterans of wars in Iraq and Afghanistan have taken up residence.

"Such groups do not exist on the soil of the Gaza Strip...there are no fighters in Gaza except Gazan fighters," he said.

Such "Zionist propaganda" from Israel was simply an attempt to turn the world against Hamas, he said.

A Hamas spokesman said Saturday that Moussa had ties to Palestinian Authority security forces.

Hamas official Sami Abu Zuhri called Moussa's speech "wrong thinking" and in a clear reference to Al-Qaida added that his group "has no affiliation with foreign groups". Hamas's Interior Ministry was blunter, calling Moussa "mad".

His group announced its existence in Gaza two months ago, after three of its members were killed in a border raid on an Israeli base in which gunmen rode on horseback.

Outside the mosque on Friday, nearly 100 masked fighters of the group in Pakistani-style dress, wearing their hair long in a style believed to imitate the prophet Mohammad, carried automatic weapons and rocket-propelled grenade launchers.

Men of the Hamas armed wing and security forces took positions nearby. The group accuses Hamas of oppressing them, including making arrests and confiscating weapons.

Human rights groups last month criticized an order by a Hamas-appointed judge that women lawyers cover their hair, and a campaign by its religious affairs ministry to encourage the public to follow Islamic instructions.

Moussa warned Hamas against implementing a decision to take over the mosque where he leads prayers for his followers: "If they approach the mosque they should know their days will be cut short," the grey-whiskered cleric said.

Moussa said his group would not initiate attacks against Hamas but "whoever sheds our blood, his blood will be shed."

He urged "everyone who has a weapon" to join the group and carry out decisions to be issued by the armed wing in coming weekly sermons. The group believes democracy is prohibited by Islam because it follows earthly law instead of God's word.

"Who are you afraid of? America? Britain? France? The European Union? You should fear only God," Moussa said in a warning to Hamas leaders seeking dialogue with the West.

Saeb Erekat, a senior peace negotiator with Israel and a member of the rival Fatah group in the West Bank, described the situation in Gaza as alarming.

"Gaza is going down the drain in chaos and lawlessness," he told the Associated Press.

Jund Ansar Allah first came to public attention in June after it claimed responsibility for a failed attempt to attack Israel from Gaza on horseback.

Israel unilaterally ended its occupation of the Gaza Strip in 2005 and withdrew its forces. Islamist radicals began to surface in Gaza following the takeover of the Israeli-blockaded enclave by Hamas in 2007, when it routed the forces of the secular Fatah movement of Palestinian President Mahmoud Abbas.