Some of the cultural strictures we associate with Islam today took a slow and winding path to acceptance. Medieval Persia (modern-day Iran), for example, gives us many beautiful illuminations and other artwork with Muhammad's face.
I also have an earlier answer on medieval Islam and alcohol:
How does that expression go..."The only thing medieval Muslims liked more than complaining about people drinking wine, was drinking wine"?^1 The writers fuming about street parties in thirteenth-century Cairo would certainly have agreed.
The Fatimid caliph al-Hakim (985-1021) gave total prohibition a try. But when he "vanished" (as it were) in 1021, his sister Sitt al-Mulk took over. One of the first things she did was re-legalize wine.
There's more to the story than that, obviously. Al-Hakim's ban on alcohol was just one part of a series of what he saw as religiously motivated reforms. He banned music in public, and he sharply oppressed Egypt's Jewish and Coptic Christian populations. Al-Hakim had gradually developed a hard-line interpretation of his religion over the course of his rule, under the influence of his adviser Bardawan. Then a religious movement decided he was semi-divine, and he may or may not have believed them.
But even during al-Hakim's attempted prohibition, local governors in places like Damascus were permitting the sale and purchase of wine anyway.
Sitt al-Mulk's reforms of al-Hakim's reforms, too, were much more in depth. She restored a lot of seized property to Jewish and Christian Egyptians, for example, and stamped out the prohibitions on public performance of music, women in public, and so forth.
She also probably ordered the assassination of the Damascus governor who had always allowed wine, so there is that.
The other infamous example of (attempted) alcohol prohibition in the medieval Islamic world is the Almohad dynasty in high medieval North Africa and al-Andalus (Iberia). Ibn Tumart, sort of the father of the Almohad movement, was dead-set against wine. Later tradition is filled with anecdotes (true or not) of him, personally, overturning wine barrels or smacking people with his staff.
As Allen Fromherz translates it, there's even one anecdote in which he yells at a group of enslaved men for drinking. They snap back at him, "Who made you the morality police?" Ibn Tumart stares them down and declares, "God and his Prophet."
As with al-Hakim, but without the claims of semi-divinity and with a much longer implementation, the Almohad crackdown on wine was accompanied by a lot of other harsher moral measures and oppression of Jews and Christians. (Didn't stop the Almohads from hiring mercenaries of any and all religions. But, you know, the rest of 'em.)
In general, though, the thing to remember about alcohol prohibition in the medieval Islamic world is--Muslims weren't the only people there. Sure, sometimes Muslims themselves were not allowed to purchase/sell wine to each other, either by law or by peer pressure.
But there were Greek Christians, and there were Latin merchants, and there were travelers to bribe as go-betweens. And European Christian pilgrims to Jerusalem, for their part, drank a WHOLE lot of wine.
~~
I should add that the use of wine and drunkenness in Islamic religious poetry, as a trope, should be taken as allegory rather than Tales from a Madrasa Dorm. The struggle to put the, let's call it the experience of God, into words isn't unique to a single religion or era. Christian writers from late antiquity onwards have used what some people interpret as erotic (and others as baldly sexual) allegories to describe encountering God--including (presumably) lifelong-celibate authors.
I have a brief answer on medieval women writers and bridal mysticism, if you're interested in exploring that idea further.
~~
^1 It's actually: "The only thing medieval historians like more than complaining about historical inaccuracies in movies about the Middle Ages, is movies about the Middle Ages."