GAZA  An acute struggle is emerging within the Hamas movement, which rules this coastal Palestinian strip, over the extent and nature of its Islamist identity. Guardians of religious morality, some self-appointed, others from within the government, have sought to impose their views in recent months.

So far, top government officials have pushed them back, but it remains unclear for how long.

Examples of the battle abound. The most threatening occurred in mid-August when an extreme group called the Warriors of God commandeered a mosque in the southern city of Rafah and, calling Hamas impure and collaborationist, declared strict religious law to be in force. Hamas forces surrounded the mosque and, after an all-night gun battle, killed about two dozen people, including the group’s leader, and arrested 155 others, Hamas officials said. The Interior Ministry is now monitoring mosques and sponsoring public lectures against Muslim extremism.

Other cases involved no violence but plenty of coercion. The chief justice decreed this summer that female lawyers must wear the hijab head covering in court. A committee set up by the religious affairs ministry sent men along the beaches instructing bathers not to touch each other in public and to cover up. And a number of teachers and headmistresses in girls’ high schools told their students to dress in long coats and hijab rather than the jean skirts of past years.

All of those rules have already been reversed. Prime Minister Ismail Haniya told the chief justice, Abed al-Raouf Halabi, to rescind his order to female lawyers, and he did so.