AIN LEUH, Morocco — For years, this mountain village with its crumbling whitewashed walls was known locally as the place to go for sex. Women — some dressed in tight jogging suits, some in dressing gowns — dallied in the tiled doorways off the main square, offering a Moroccan version of Amsterdam’s red-light district.

But no more. A band of men here, known as the Islamists, took matters into their own hands last fall.

The men deny that they were on a religious campaign, or that they are fanatics. They were tired, they said, of living side by side with drunken, brawling clients, tired of having their daughters propositioned as they headed home from school, tired of being embarrassed about where they lived.

“It reached a point after Ramadan,” said Mohammed Aberbach, 41, who helped organize the campaign to drive the prostitutes out of town, “that men were actually waiting in lines. It was crazy.”

These days the side streets are quiet. The doors, painted green and yellow, are mostly shut, though a few prostitutes remain, now trying to sell candy instead of sex. In the square, the pace has slowed, fresh chickens and slabs of meat hang for sale on hooks, and villagers take their time over displays of vegetables. Nearby, women are bent over looms making traditional Berber rugs.

The changes in Ain Leuh are being held up by some in Morocco as another triumph of the Arab Spring — testament to what can happen when ordinary citizens stand up for change and make life better for themselves.

For others, however, the events of the past year show how the more fundamentalist Islamists, though continuing to be shut out of power in countries like Tunisia, Egypt and Morocco, nonetheless manage to promote their conservative agendas — often taking the law into their own hands, and in this case threatening the prostitutes and their customers and driving away the only industry in these parts.

“The economy is in free fall here,” said Ali Adnane, who works for a rural development agency. “The girls rented. They had cash. They bought things. Some people here are really happy about the changes. But some people are not.”

Morocco has avoided much of the violence that has gripped Arab countries in the last few years. In the face of mounting protests, Morocco’s king, Mohammed VI, offered to curb his own powers and in 2011 pledged a variety of reforms. Since then, the country has adopted a new Constitution and elected a new government, led by a moderate Islamist party.

The new prime minister, Abdelilah Benkirane, who has refused many of the perks of his office, has a flair for mingling with the average man. But many remain frustrated over the pace of change in a country plagued by high unemployment and corruption. Ain Leuh is hardly the only village to have seen the emergence of a local committee, known as a comité, pushing for reforms of various sorts.

Exactly what happened in this village of 5,000 in the Middle Atlas Mountains, about a two-hour drive from Rabat, the capital, is in dispute. Mr. Aberbach says the Islamists never did anything illegal. The campaign, he said, largely involved demonstrations in the main square. No one threatened anybody or used violence or stood at the entrances to the village demanding identification from men who wanted to enter.

“That would be against the law,” said Mr. Aberbach, a friendly man who owns several shops here and has big plans for the future of Ain Leuh.

But others, including Haddou Zaydi, a member of the town council, say all those things, and more, took place. Sometimes, he said, the Islamists used padlocks to imprison the prostitutes in their houses after a customer had gone in. Then, they called the police.

In the past, many here say, the prostitutes would pay off the police to look the other way. Now, though, the authorities, still getting the feel for a newly elected government led by a moderate Islamist party, the Justice and Development Party, let the Islamists have their way.