Fes is one of the four so-called "imperial cities" (the others are Marrakesh, Meknes and Rabat). Fes is separated into three parts, Fes-al-Baldi (the old, walled city), Fes-Djedid (new Fes, home of the Mellah), and the Ville Nouvelle (the French-created, newest section of Fes). The Medina of Fes-al-Baldi, the larger of the two medinas of Fes, is believed to be the largest contiguous carfree urban area in the world.

The city was founded by Idris I in 789. In 810 the Kairouyine mosque, one of the oldest and largest in Africa, was built by Idris II, and the associated university was founded in 859. The city was populated by Muslims from elsewhere in North Africa, the Middle East, Moriscos, as well as many Jews, who had their own quarter, or Mellah, in the city.

Fes became the center of the Alaouite Dynasty in 1649, and it was a major trading post of the Barbary Coast of North Africa. Until the 19th century it was the only source of Fez hats (also known as the tarboosh), before they began to be manufactured in France and Turkey; originally, the dye for the hats came from a berry that was grown outside the city, known as the Turkish kizziljiek or Greek akenia (Cornus mascula). Fes was also the end of a north-south gold trading route from Timbuktu.

Fes was the capital of Morocco at various times in the past, the last such period ending in 1912, when most of Morocco came under French control and Rabat was chosen to be the capital of the new colony, a distinction that city retained when Morocco achieved independence in 1956. While many of the original inhabitants of Fes have since emigrated, the Jewish quarter has been emptied of its Jewish population, and the economy has stagnated, Fes is perhaps the most interesting and picturesque of the Imperial Cities of Morocco.

The economy is also in a state of rapid recovery since the fame of the annual Fes Festival of World Sacred Music spread worldwide. Thousands of visitors now converge on the city every year to experience a unique week-long celebration of sacred musical traditions from every corner of our planet.Famous performers like Ravi Shankar, Youssou N'Dour and Salif Keita are juxtaposed with more obscure musical genres such as Japanese Gagaku, Indonesian Gamelan and folk music from Central Asia.

The 2007 festival promises to be a vintage year, with new Artistic Director Cherif Khaznadar bringing a fresh perspective to the programme. The festival was founded in 1994 by the Moroccan scholar and philanthropist Faouzi Skali. It includes a four-day Forum under the rubric "Giving Soul to Globalisation". Politicans, social activists, visionaries, academics and religious leaders come together in dialogue. The Forum is Sponsored by the World Bank. Fes is becoming an increasingly popular tourist destination and many non-Moroccans are now restoring traditional houses (riads and dars)as second homes in the Fes medina.