Fes's medieval medina is a maze without maps, dedicated to trade. Get lost in this walled city-within-a-city - but don't forget to buy something
The flags were out in Fes, hanging limply in threes along routes into the city and dressing up the Ville Nouvelle with a bloom of scarlet cloth. Along Avenue Hassan II, the national flag was stretched across every shopfront and over the canopies of pavement cafes, casting a pink shadow over the groups of men sipping coffee or mint tea. Out in the street, workmen resurfaced the road to the royal palace while others hastily covered doors and walls with a fresh coat of paint. The new king was due any day.

Crown Prince Sidi Mohammed was sworn in as King of Morocco in July, following his father's death. And, after 40 days of official mourning, the country's mood had begun to swing to one of expectation as Mohammed VI set out on a tour of his kingdom.

Fes was a significant stop for the new king. Founded in the 9th century, Fes was the capital of Morocco's first Muslim kingdom. It retained this position for many centuries, reaching its peak during the 13th and 14th centuries, under the Merenid dynasty, when the city was known as the "Baghdad of the West".

As subsequent dynasties shifted Morocco's political focus to newer administrative centres at Marrakesh and Rabat, however, the city's stature began to weaken. Today, its notoriety centres on its claim to be the Arab world's most complete medieval city and its wealth has become increasingly reliant on tourism.

Not all tourists in Fes can expect a flurry of flag-waving and fresh paint, but they can expect the full attention of the Fassis: Fes isn't a city into which you slip unnoticed. Step off the train or out of a taxi and you will soon be offered the services of a guide. Come by car, and they will pull alongside on motorbikes touting for business through the driver's window. Whether you see this as helpful or harassing, Fes is a disorientating place to arrive in, and a little guidance on your first day can be very useful.

The city comprises three distinct parts, each scattered through the wide, hill-fringed Sebou Valley. Spilling down onto the valley floor is Fes- el-Bali, the walled medina. West of the medina is Fes Jdid, or Fes the new - built late in the 13th century and dominated by the walls and grounds of the royal palace. A kilometre further west is the Ville Nouvelle - built early this century, under the French Protectorate - with wide avenues and all the conveniences of a modern city.

Tourists usually head straight to the medina, a walled labyrinth of 9,000- odd narrow streets and alleyways. Guide-book illustrations are useful for defining its shape and locating the entrances and landmarks. The Royal Geographical Society has a German WWII map, but once you're lost in the crowds behind the walls, you're pretty much on your own. Most visitors hire a guide for at least half a day. I arranged mine through the hostel where I was staying, but if you haven't pre-arranged one, don't worry, they'll find you.

It's packed as soon as you are inside. We push our way through a bustling fresh-produce market strung out along a narrow lane striped with light streaming through a slatted wooden roof. The shafts of light are opaque with the dust kicked up from hundreds of shuffling feet, flapping livestock and traders unloading sacks of produce. It is a magical scene, but there is no time to take it all in, only to snatch glances as we are hustled along. Great sticky piles of dates, baskets of olives, quivering mounds of glistening offal.

Four or five turns in and I've lost my bearings. I'm led through the knife-sharpeners' district and on through the metal workers' district, where fathers and sons furiously hammer huge pots and trays into shape. Every so often we duck into a doorway, giving way to a heavily laden mule. Too narrow for vehicles, goods are moved around the medina as they always have been. What has changed, however, are the loads that they carry - anything from a huge stack of Coca-Cola crates to satellite dishes.

My guide isn't particularly chatty, despite my barrage of questions, and his perfect English. His commentary, though informative, feels as if it's the same old spiel he has been rolling out for years. Nevertheless, we are quickly racking up the key sights, nosing through the doors of the great Karaouiyne Mosque - which is hardly visible in the warren of streets at the centre of the medina, but large enough to accommodate 20,000 at prayer - then on to the Attarine Medersa, arguably the finest of the medieval colleges that are scattered throughout old Fes.

On the way, we stop and listen to the shrill tones of children reading aloud inside a tiny Koranic school and sample delicious fresh-baked bread at one of the hidden wood-burning bakeries. One of the most memorable sights, and smells, though, is the Chouara tannery, best viewed from the rooftops around its edge. In a scene unchanged for centuries, craftsmen work thigh-deep in a honeycomb of vats filled with lime, urine, pigeon droppings, tannin and coloured dyes, processing raw animal skins into fine leather.

Most guides will end their tour in the crowded souks, giving the hard sell at various shops and co-operatives. Though sometimes irritating, it's all part of the tour and should be enjoyed. Trade is, after all, at the heart of life in the medina. But be sure of what you do and don't want to buy. The indecisive will be pounced on mercilessly.

After half a day with a guide, you'll have seen most of the main sights and gained the confidence to go back in unaccompanied. This time, let yourself be guided by the medina itself, led by whatever rouses the senses. Explore the narrowest, darkest streets. Peek through hidden doorways. Wander into the quieter residential streets of the Andalous quarter. Enjoy getting completely lost.

If you do have a plan, make sure it includes an exit through Bab Jamais on the northern side of the medina - and the site of the luxurious Palais Jamais Hotel. This former palace has space and tranquillity that you'll crave after a day wandering through the medina. Stay for a meal in the traditional Al Fassia restaurant, or a drink in the beautiful tiled Andalusian garden and, flags or no flags, you'll be treated like a king.

Jon Winter travelled as a guest of Royal Air Maroc (0171-439 4361), which flies five times a week from Heathrow to Fes via Casablanca. Current fares start at pounds 290 return. He stayed at the newly refurbished Youth Hostel (18 Rue Abdeslam Serghini, Ville Nouvelle, 00 212 5 624085), which is run by the friendly, English-speaking Abdul, and costs 50 dirhams (pounds 3) a night.

Official guides can be hired at either of the two tourist offices in the Ville Nouvelle, or at the booth beside Bab Bou Jeloud, the main entrance to the medina. They charge a flat rate of 120 dirhams (pounds 7.50) for a half day regardless of how many of you there are.

Alternatively, take one of the many unofficial guides that hang around the main gates and tourist spots - but settle fees and an itinerary over a glass of mint tea before making a decision