Some musical festivals, such as Glastonbury or Womad, transform an open field into a festival space, while others - Fez, for instance - are inspired by the location itself and use the specta cular architecture of a particular city. Few, however, marry the music, the message and the magic so successfully as Fez.
Fez is Morocco's Granada or Florence. From 808, when Fez was declared the capital by Moulay Idriss II, it became the country's cultural, spiritual and political heart for more than a thousand years until the administrative centre was moved to Rabat by the French in 1912. Actually, that was a blessing for the survival of the Old City of Fez, which has the most extensive medina in the world with Unesco World Heritage status.
At the heart of the medina is the shrine and tomb of Moulay Idriss II - an important place of pilgrimage that throngs with people. Close by is the Karaouine Mosque, the largest in Morocco, until the Hassan II Mosque opened in Casablanca in 1993. The Karaouine is the centre of spirituality and learning: dating back to the 9th century, it is one of the oldest universities in the world. The green roof tiles of the mosque and shrine have become the city's architectural symbol, and it is the spiritual traditions rooted here that have inspired its Festival of Sacred Music.
It was started in 1994 by the Fez-based scholar Faouzi Skali, who wanted to counter the polarisation of the Arab world and the west after the first Gulf War. "I wanted to create a place where people could meet and discover the beauty of each religion and culture," he explains. "Fez has a message that it can pass on to the world today."
The idea is simple - to present spiritual music from all over the world, of any creed or faith. It began with the three monotheistic faiths - Islam, Judaism and Christianity, all part of the cultural history of Fez - but now includes Hinduism, Buddhism, animism and more. This year there will be sacred dance from Bali, the Norwegian Sami singer Mari Boine, Huong Thang from Vietnam, and Christian and Muslim hymns to Mary from Damascus. Even the definition of spiritual is pretty loose. Last year Angélique Kidjo declared from the stage: "Life is sacred and I sing about life." Other big-name artists who have appeared are Salif Keita, Gilberto Gil and, coming this year, Jessye Norman. One of the most memorable was Youssou N'Dour, who in 2004 premiered his amazing Egypt album, dedicated to Muslim saints, one of whose shrines is also in the heart of the Fez medina.
The big evening concerts take place against the keyhole-shaped arch of Bab Makina, a former monumental gateway to the royal palace. Five thousand seats are set out beneath the ochre-coloured walls. In the late afternoon, more intimate, and often more powerful, performances take place in the courtyard garden of the Batha Museum. With the stage in the shade of an ancient barbary oak full of birds, it has the aura of a holy space. Here it is best to ignore the seats, slip off your shoes and sit on the carpeted platform just in front of the stage. It's a real privilege to witness performances in a setting like this. At both venues the sound quality of the PA system is first-rate - something that's all too rare at festivals.
Each evening from about 6.30pm there are free concerts on Bab Boujloud. It's a magical time, just as the light is starting to dim in the square and thousands of starlings that live in the city walls dart and dive over the crowds of people who have come to hear the music.
From Bab Boujloud, it's just a few steps to the Old City of Fez. The cafes, street carts and food stalls here give a foretaste of what you will find within. The smells are pungent and vivid. Grilling kebabs and decorative piles of the most delicious olives in the world sit right next to a severed goat's head dripping blood. And then you're off into the labyrinth of narrow lanes and blind alleys - only just wide enough for pedes trians and donkeys. If you get shouted at as you wander, it's because there's a donkey-driver behind you trying to get past. Because cars can't make it in, traditional production techniques have survived. There are fascinating workshops scattered across the city: textiles, wool, pottery, slippers, skins, drums.
Some of the most thrilling music of the festival can be heard at the Sufi nights that take place from 11pm outside a tiled pavilion in the garden of Dar Tazi, the Palais de Fez, on the edge of the medina. Sufism, a mystical branch of Islam, is very widely practised in Morocco and the dozen or more brotherhoods active in the country today use music as a medium for getting closer to God.
The Sufi nights are free and popular with Moroccans and visitors alike. You sit on carpets and cushions around a fountain and the Sufis take you into another world. The music of each brotherhood is very different, so the sounds, textures and ambience are never the same twice. One night it might be Arab-Andalus style with oud, violin and goblet and frame drums; another night it's rhythmic chanting and no instruments at all; then perhaps the Hamadsha, with a deep lute, drums and trancelike dances; and the Aissawa, who are the most spectacular of all, with a bevy of different drums, oboes and long cere monial trumpets. Over the course of a week you can get a primer in the varied sounds of Moroccan Sufi music. OK, it's not a real Sufi ritual, but it's as close as you're likely to get in Morocco, where non-Muslims generally aren't permitted to enter mosques and shrines.
Morocco has consciously positioned itself as a moderate, western-leaning Islamic country and somebody among King Mohammed VI's advisers must have decided that music festivals are a way to bring in visitors and promote a positive image to the world. Aside from Fez, there are festivals of international quality in Rabat, Casa blanca, Tangier, Essaouira and Agadir. But here, as the sound builds to a frenetic climax, you get a sense of the deep culture and spirituality emanating from this particular city and this festival, which make Fez the extraordinary place it is.
The Fez Festival of World Sacred Music takes place from 6-15 June. http://www.fesfestival.com