At least since the 17th Century, this place has been the heart and soul of Marrakesh, a meeting place for residents of Morocco and tourists from around the world.

No one could have planned the Djemaa el Fna. It is too fantastic to be anything other than a happy accident of time, space and people. At least since the 17th Century, this place – referred to locally as la place – has been the heart and soul of Marrakech, a meeting place for residents from the medina and Berbers from the mountains, Moroccans from elsewhere in the country, expats home for a holiday and tourists from around the world. When Queen Victoria sent a present of an elephant to the sultan of Morocco, this was where it was displayed. When, just a hundred years ago, the pasha of Marrakech had one of his regular settling of scores, his enemies were executed here, their salted heads hung on the nearby city walls. These days when the sun goes down, it is food rather than elephants or executions that draws the crowds.

There is an order to the apparent chaos. The day starts with the arrival of the sellers of fresh orange juice, the nation's bounty. They are followed in the late morning and early afternoon by fortune tellers, diviners of various techniques, with their charts and charms, by people who claim to be able to cure broken hearts and others who occupy themselves with broken bodies, their stalls an assembly of snake skin, chameleon and desert fox, dried herbs and wild trees. Business might be slow, but along with the fortune-tellers and healers, the henna tattooists, acrobats and gnaoua, the spiritual musicians, they know the importance of claiming your space before the sun goes down and the big breaks come.

At sunset, the place is filled with food stalls, ranged in tightly drawn rows, benches for the diners, strings of lights overhead, food banked up in the middle and beside it, a griddle. Most stalls tend to specialise in one particular dish, but between them they offer an opportunity to sample a good selection of Morocco's traditional food.

On one side they are serving up bowls of snails flavoured with thyme, chilli, lemon and orange. On another, fresh-cooked sheep's heads are laid in a row like the old pasha's enemies. Harira, the famous lamb, lentil and chickpea soup of Fès, is ladled out, accompanied by big fat dates from over the Atlas Mountains. One stall sells small fried sole, another eel, its neighbour a ginger and date sweet and short glasses of ginger tisane. At the centre of all this, there are rows of tagines, mounds of couscous, and the grills, smoke rising from beef brochettes and lamb sausages like incense in some pagan temple.

The part of the place not given up to food is filled with people. It is dark, crowded mostly with Moroccans. In the gloom, there is a sense that anything could happen, that over the centuries much has happened. Into the chaos, the fumbling in the dark, an order is imposed as people form circles around performers, a troupe of acrobats, jugglers and escape artists, a comedian, a group of musicians, a story-teller... this is trial by public jury: if the performance falls flat, the tricks fail to amuse or the stories to amaze, the crowds move on.

Around eight or nine o'clock, the souks recently closed, the place is at its peak with thousands of people in the square. After that, the crowd thins out as women and children wander off home, tourists return to their hotels. By 10, 11, the audience is almost exclusively male. By midnight, some of the stalls have gone and many of the performers, the henna tattooists, the diviners and herbalists have packed up. Another hour, two at the most and the place will be empty, just another stretch of pitted, stained tarmac waiting for the dawn and the people to bring about the daily miracle of its recreation.

The article 'Djemaa el Fna, the beating heart of Marrakech' was published in partnership with Lonely Planet.