Ismail Helou was working at his family's petrol station on a Thursday afternoon when a police jeep pulled up. The plain-clothed officers ordered him to get into the vehicle. He was blindfolded and taken to a police station, where his legs were bound to a wooden plank and the soles of his feet were repeatedly beaten with a plastic pipe. Then they tried to shave off the gelled spikes of hair on his head.

"I was screaming and crying. It was the most painful thing I have ever faced. My feet were blue and I couldn't walk for three days," he said. Bruises on his soles were still visible three weeks later.

After the ordeal, Helou, 22, went to a barbershop to get his ravaged hair cropped. Now shorn of his one-inch spikes, he has been given no reason by the police for his detention and beating. But his experience is shared by other young men in Gaza City.

Over the past month, at least 40 men have had their heads shaved by Hamas officers in a pattern of intimidation and abuse aimed at enforcing Islamic mores governing personal appearance, according to the human rights organisation Al Mezan. The individuals have been targeted for sporting "western" hairstyles or wearing low-slung jeans that reveal underwear. But one, to whom the Guardian spoke, insisted he was guilty of neither "offence", but was beaten and shaved simply as a mechanism of social control.

Rajou Hayek, 33, was bundled into a police jeep by eight men as he was taking his father, who was in a wheelchair, to a health clinic. Handcuffed and with his T-shirt pulled over his head, he was driven to a police station where he glimpsed a "hill of hair" on the floor. "They beat me all over my body and shaved my head. I was crying. This is not about jeans and hairstyles. They want to make people in Gaza afraid of them."

Human rights organisations and analysts in Gaza say Hamas has revived a drive to impose Islamic social codes and behaviour in the tiny coastal territory it has controlled for the past six years. They cite a string of recent developments, including a new law to enforce gender segregation in schools and a ban on women's participation in a marathon that resulted in the UN, its organiser, cancelling the event.

Earlier strictures included a prohibition on women smoking shisha pipes in public and riding pillion on motorcycles, and an attempt to force schoolgirls to observe religious dress codes. Some call this creeping "Islamicisation"; others say it has nothing to do with religion, describing it instead as "Hamasisation".

But the humiliating and dehumanising punitive act of shaving heads is as likely to breed deep resentment of Hamas as it is to enforce behavioural conformity, say independent analysts.

According to Samir Zakout of Al Mezan, Hamas is attempting to control Gaza's cultural environment by taking action against those whose behaviour crosses the acceptable boundaries of a socially conservative society. "Gaza is today more Islamicised than when Hamas took power. And I think it's getting more so," he said.

But there was also a political dimension. "This is partly directed at Hamas members internally. Hamas was elected promising an Islamic state and some of their own supporters complain that it has not been implemented," he said. This led to the formation of some extreme fundamentalist factions which put Hamas under pressure to prove its Islamist credentials.

Mkhaimar Abusada, a political scientist at Al Azhar university, said Hamas in Gaza may also be trying to convey a message to the relatively more moderate leadership in exile. "There has been an internal conflict within Hamas for at least a year. Radical elements lost out in the recent politburo elections, but are still in control of Gaza. They are sending a message that they decide what happens here."

Al Mezan knows of 40 cases of boys and men having their heads shaved since 5 April. Most of the punitive actions are linked to so-called western hairstyles or low-waisted jeans, but Zakout says there have been three cases of young men having their heads shaved for illegally hawking cigarettes on the street.

Ihab al-Ghusain, head of the Hamas government media office, said the practice had stopped. "If we want to change habits, we have to persuade people, not force them," he said. But, he added, "the majority of people support our philosophy. Hamas is defending what families in Gaza want. Young people should be concerned about education and the occupation, not looking at singers' haircuts. Pop stars are not appropriate role models."

For Helou, who used to spend 20 minutes each morning coaxing his hair into spikes, which he said were much admired, Hamas's clampdown on self-expression has left him angry and frightened. Even so, he plans to regrow his hair.

"If I had the chance I would flee from Gaza but my work and my family is here," he said. "Hamas is getting stricter and stricter. We are already under pressure, there are so many troubles. And now it's our jeans and hairstyles? This is too much."