TEHRAN — For most of his life, alcohol rehab for Mehdi consisted of regular stretches in prison and lashings that left dark marks on his back. Now, at 36, he has prematurely gray hair, but with the help of an Alcoholics Anonymous group he swears he has finally stopped drinking.

In recent years, Iran, where alcohol has been illegal since the 1979 revolution and is taboo for devout Muslims, has taken the first step and admitted that, like most other nations, it has an alcohol problem.

Since 2015, when the Health Ministry ordered addiction treatment centers to care for alcoholics, dozens of private clinics and government institutions have opened help desks and special wards for alcoholics. The government has also allowed a large and growing network of Alcoholics Anonymous groups, modeled after those in the United States.

The relaxing of prohibition has allowed addicts like Mehdi to emerge from the shadows and embrace a new circle of friends — recovering alcoholics — who greeted him as he entered a West Tehran apartment one recent evening. “I’ve given up the bottle for 12 days now,” said Mehdi, a tall computer specialist who requested anonymity because of the stigma still attached to alcoholism in Iran. To cheers and hoots, he added, “This is a big step for someone who was drunk most of the time.”