They did so in spite of religion though. That's an important distinction.
For instance the following quote from Wikipedia illustrates the dichotomy between religion and science in Al Andalus...
When Al-Hakam's son Hisham II took over, real power was ceded to the hajib, al-Mansur Ibn Abi Aamir. Al-Mansur was a distinctly religious man and disapproved of the sciences of astronomy, logic, and especially astrology, so much so that many books on these subjects, which had been preserved and collected at great expense by Al-Hakam II, were burned publicly.
In other words, the scientists and non-religious scholars who were responsible for all the progress were waging a constant struggle with the fundamentalist religious nut-cases... just like today in the Middle East. That's why the muslim culture is stale and stagnant. The Arab world's relevancy and wealth is entirely based on a decomposing jurassic jungle under the sand. They have done nothing themselves to evolve.
That was mostly for show, in order to keep on the good side of religion. It was (and still is) a system for population control that the rulers used against the masses. But they themselves were not bound by it. I suspect, neither were the religious leaders. A bartender never drinks while working.
That is certainly a possibility. I could be totally wrong.
When I kick the bucket I'll find out I guess. Maybe I will go to the afterlife and meet a bearded dude with a big turban:
"Yo Gafle! I'm known in this hood as Allah the Great, and you have pissed me off royally since the day you were born. So instead of 72 virgins you're getting 72 hamsters and a roll of duct tape. Enjoy eternity! Heh heh heh..."