The Andalusian musical tradition flowered out of a combination of cultural forces that both incorporated and transcended local traditions. The Muslim conquest of Spain under the Umayyad Caliphate beginning in 711 heralded an exchange of various forms of culture, music included. Under the successors of the Umayyad Dynasty, who established and held a court in Cordoba until the early 11th century and which remained a cultural force in the region for centuries after, a distinct form of Arab-Andalusian-North African music arose. During the initial period of the Islamic Empire, the indigenous musical traditions of Spain coexisted with Afro-Arab traditions. It was during the second phase of Islamic rule in Cordoba, under which music was encouraged, that Ziryab, the legendary founder of Andalusian music, synthesized the two traditions and founded a conservatory.

The culture and music of Al Andalus was influenced and spread by patterns of immigration among the Mediterranean world. The interplay of religious groups in the area was also significant. Until the strict Islamic rule of the Mowahad Dynasty (1147-1269), relative religious tolerance of coupled with the decline of the previous center of Jewish intellectual activity in Babylonia, Al Andalus became a center of Jewish culture.

During the Moravid Dynasty (1055-1147), Morocco and Andalusia were united under one empire, an empire that encouraged scholarship and the arts. Andalusian music emerged as a popular form of expression, combining song and dance and instrumental accompaniment. While Andalusian music was at this time a secular practice and the lyrics associated with worldly matters, some scholars say the connection between Andalusian music and mysticism dated back to the time of Ziryab: Mamoud Guettat claims in his article “The Andalusian Musical Heritage” that “the mysterious, magical, mystical and religious side of the music, as well as its expressive and therapeutic aspects and its effects on the human soul (its ethos), are part of the foundation of the Andalusian-North African musical edifice.” Guettat goes on to describe Ziryab’s outlook on music as “an expression of mystical aspirations dear to the traditional Arabic school.” (448)

Though Andalusian may well have had spiritual connections since its founding, official attitudes towards music and the secular activities associated with it changed sharply with the arrival of the Mowhad Dynasty in 1147. Religious tolerance lessened and music was declared haram or forbidden. Musicians were arrested and instruments were destroyed. To escape persecution for practicing music, musicians hid books in pillows and instruments under beds. It was during this time that Sufi practitioners began to be active in zawaya, performing the same Andalusian music using voice instead of instruments. Some brave musicians would wear a jellabe or cloak under which to hide their instruments and sneak them into the zawiya. Similarly, this music was conserved by continued practice in synagogues.

This process of conversion from secular to sacred, known as contrafactum, was prevalent in other parts of Europe at the onset of the Middle Ages and also under the Mowhad regime in Andalusia and North Africa. In both places of worship, zawaya and synagogues alike, Andalusian music was maintained using the same melodies, the same rhythms, the same dynamics and the same structure. Only now, Sufis and Jews changed the lyrics from secular to pious to suit their respective religious goals, voices replaced melodic instruments and bodies became substitutes for drums. Since the era of the Mowhad Dynasty, during which Andalusian music became incorporated into mystical religious practices of Morocco’s Muslims in zawiyah (pl.) and Jews in synagogues, the music has been conserved by these two groups in much the same form, just using different languages.

One example of an Andalusian piece that underwent the transformation from secular to sacred is Nouba Raml al Maya. The over 500 verses comprising this nouba, one of the original 24 codified by Ziryab, were changed by the Sufi community of Morocco from secular to religious content. The melody, rhythm, and structure have been maintained.