It begins with a photograph. It’s a blow-up of a faded colour picture of the Great Mosque at Djenné, in Mali, from some time in the mid-20th century. In the picture, the largest mud structure in the world still looks healthy. But already there is a slight plumpness to it. The pilasters, once sharply squared, have become rounded so that they are more like ripples across the surface of the mud walls. The corners of the towers have softened, the once-sharp crenellations are blunt, the windows are in the process of closing up – tiny eyes behind swelling lids. The mosque is still growing. It is in mid-transformation, on its way to becoming the fleshy organism lovingly preserved on postcards and in National Geographic features.

This battered old photograph sits in a house on the road into Djenné, the temporary quarters of the architect Abd El Kader Fofana. A specialist in Malian heritage who studied architecture in the former USSR and speaks fluent Russian and Chinese, Fofana is one of those characters you find in Africa who confounds complacent European expectations. He was hired by the Aga Khan Trust for Culture to supervise the restoration of the mosque. As Mali’s most symbolic piece of architecture, located in the oldest-known city of sub-Saharan Africa, the mosque is the most sensitive of the AKTC’s development projects in the country. When the initial tests were made on the building in 2006, which involved excavating some of the earthen surface of the roof, the citizens of Djenné rioted. Cars were destroyed, the mayor’s house ransacked and one person was killed. After the perceived sacrilege of the structural test, it took a year to persuade the people of Djenné that their mosque was in danger of collapse.

It’s April, and 47ºC in Djenné. Standing on the raised platform around the base of the mosque, you can feel the heat of the mud floor through the soles of your shoes. Fofana points out cracks in the perimeter walls. When it rains, these allow water to penetrate the core. The problem, he says, is that the structure is rotten. Last November, the north-east tower came crashing down, but it has already been re-erected. The locals have a tradition that is supposed to prevent this kind of thing from happening. Every April or May, before the rainy season, they re-plaster the mosque with a fresh layer of mud, both to seal it and to restore whatever was washed away by the previous year’s rains. Residents of the east side of town re-surface the eastern half of the mosque, those from the west do the western half. It’s a ritual. In fact, more than that, it’s a festival in which everyone participates. In Spain they throw tomatoes, here they clamber up the walls to slap mud.

In a sense, the mosque has suffered from too much love. Year upon year, the citizens have been putting back slightly more mud than was eroded by the rain. Almost imperceptibly, the building was morphing, like a child being overfed by a doting mother. Eventually, it was groaning under the weight of its multiple skins. The bones were buckling. It needed liposuction.

Non-muslims are not allowed inside the mosque, but Fofana leads the way. The men’s prayer chamber, with its 90 columns, is dark, scattered here and there with goat-skin prayer mats. In the main courtyard, the floor is sloped. Every year the sand used to soften the kneeling of the faithful is dumped in geological layers into the courtyard. Wherever the pre-restoration mosque is visible, you can read a history of accretion. The pilasters on the outer walls have gained strange feet, the spiky battlements have become camel humps, right-angles have become curves. Under Fofana’s direction, Djenné’s guild of masons has been sloughing off the layers of earth, stripping the building back to its mud bricks. They removed 500 tonnes of earth from the roof alone – 103 years’ worth of over-feeding.

People often talk about “organic” architecture. There is no more organic building in the world than Djenné’s Great Mosque. In many ways it is a body. More than that, it bears the traces of all the bodies that have ever created it. At the foot of a wall, two masons are moulding the mud bricks by hand. Their finger marks read like cuneiform. Elsewhere, the fermented mud for the plastering is trampled by foot and applied by hand. Fofana uses the word “breathes” to describe the earth walls – concrete, by contrast, doesn’t breathe. This is a living building – fed, replenished but also purged. As such it is amazingly mutable. In European restorations we sandblast a millimetre at a time. Here a mason is stabbing the skin with a crowbar and levering off a half-foot slab of meat. The top of a tower is unsound so it is pulled down and rebuilt. This seems to require no heavy equipment.

After a year and half of work, the mosque is more than half restored. Its ribcage and cheekbones are showing. But mid-operation, there is a clear tension between the mosque’s two characters. The question is, which face is the real one?

There is no living memory in Djenné of the mosque looking the way it now does. Although there has been a mosque on this site since around the 13th century, this particular building was erected by Djenné’s head mason in 1906, at the behest of the French colonisers. Some believe that the design bears French influence, that it is too symmetrical to be entirely African. That’s as may be, but what is clear is that over the following hundred years the mosque developed a different character. The building that the townspeople know is the result of a process more than a design. This is evident from the palm beams projecting from the walls. These are not architectural structure but social. People climb this scaffolding to renew both the building and themselves in an orgy of mud. They are the support structure of the annual rite.

How do the citizens of Djenné feel about this new, svelte form emerging from under the one they grew up with? And if we treat them as two separate images, which is the authentic one? The French colonial era mosque is angular, formal, rational. The “African” one is informal, organic, in keeping with the soft curves of the surrounding town. Ironically, since it lies on top of the original form, it seems inchoate, unformed rather than transformed, still in the process of being shaped. It has the quality of a model. As the 1906 building reappears, the building is regaining its sense of scale and detail. The AKTC is clearly saving the mosque, but in doing so it is erasing a contemporary building and reinstating an image from the past.

Of course, once the clock has been reset, the ritual feeding will resume. But the annual nourishment will not be the free-for-all of bygone years, it will be carefully supervised by the masons. The mud levels will be standardised. The terracotta ventilation flues on the roof now mark the limit with a two-inch high lip. In a sense the festival has been professionalised. Reason dictates that the Dionysian rite be moderated.

It begins with a photograph. It’s a blow-up of a faded colour picture of the Great Mosque at Djenné, in Mali, from some time in the mid-20th century. In the picture, the largest mud structure in the world still looks healthy. But already there is a slight plumpness to it. The pilasters, once sharply squared, have become rounded so that they are more like ripples across the surface of the mud walls. The corners of the towers have softened, the once-sharp crenellations are blunt, the windows are in the process of closing up – tiny eyes behind swelling lids. The mosque is still growing. It is in mid-transformation, on its way to becoming the fleshy organism lovingly preserved on postcards and in National Geographic features.

This battered old photograph sits in a house on the road into Djenné, the temporary quarters of the architect Abd El Kader Fofana. A specialist in Malian heritage who studied architecture in the former USSR and speaks fluent Russian and Chinese, Fofana is one of those characters you find in Africa who confounds complacent European expectations. He was hired by the Aga Khan Trust for Culture to supervise the restoration of the mosque. As Mali’s most symbolic piece of architecture, located in the oldest-known city of sub-Saharan Africa, the mosque is the most sensitive of the AKTC’s development projects in the country. When the initial tests were made on the building in 2006, which involved excavating some of the earthen surface of the roof, the citizens of Djenné rioted. Cars were destroyed, the mayor’s house ransacked and one person was killed. After the perceived sacrilege of the structural test, it took a year to persuade the people of Djenné that their mosque was in danger of collapse.

It’s April, and 47ºC in Djenné. Standing on the raised platform around the base of the mosque, you can feel the heat of the mud floor through the soles of your shoes. Fofana points out cracks in the perimeter walls. When it rains, these allow water to penetrate the core. The problem, he says, is that the structure is rotten. Last November, the north-east tower came crashing down, but it has already been re-erected. The locals have a tradition that is supposed to prevent this kind of thing from happening. Every April or May, before the rainy season, they re-plaster the mosque with a fresh layer of mud, both to seal it and to restore whatever was washed away by the previous year’s rains. Residents of the east side of town re-surface the eastern half of the mosque, those from the west do the western half. It’s a ritual. In fact, more than that, it’s a festival in which everyone participates. In Spain they throw tomatoes, here they clamber up the walls to slap mud.

In a sense, the mosque has suffered from too much love. Year upon year, the citizens have been putting back slightly more mud than was eroded by the rain. Almost imperceptibly, the building was morphing, like a child being overfed by a doting mother. Eventually, it was groaning under the weight of its multiple skins. The bones were buckling. It needed liposuction.

Non-muslims are not allowed inside the mosque, but Fofana leads the way. The men’s prayer chamber, with its 90 columns, is dark, scattered here and there with goat-skin prayer mats. In the main courtyard, the floor is sloped. Every year the sand used to soften the kneeling of the faithful is dumped in geological layers into the courtyard. Wherever the pre-restoration mosque is visible, you can read a history of accretion. The pilasters on the outer walls have gained strange feet, the spiky battlements have become camel humps, right-angles have become curves. Under Fofana’s direction, Djenné’s guild of masons has been sloughing off the layers of earth, stripping the building back to its mud bricks. They removed 500 tonnes of earth from the roof alone – 103 years’ worth of over-feeding.

People often talk about “organic” architecture. There is no more organic building in the world than Djenné’s Great Mosque. In many ways it is a body. More than that, it bears the traces of all the bodies that have ever created it. At the foot of a wall, two masons are moulding the mud bricks by hand. Their finger marks read like cuneiform. Elsewhere, the fermented mud for the plastering is trampled by foot and applied by hand. Fofana uses the word “breathes” to describe the earth walls – concrete, by contrast, doesn’t breathe. This is a living building – fed, replenished but also purged. As such it is amazingly mutable. In European restorations we sandblast a millimetre at a time. Here a mason is stabbing the skin with a crowbar and levering off a half-foot slab of meat. The top of a tower is unsound so it is pulled down and rebuilt. This seems to require no heavy equipment.

After a year and half of work, the mosque is more than half restored. Its ribcage and cheekbones are showing. But mid-operation, there is a clear tension between the mosque’s two characters. The question is, which face is the real one?

There is no living memory in Djenné of the mosque looking the way it now does. Although there has been a mosque on this site since around the 13th century, this particular building was erected by Djenné’s head mason in 1906, at the behest of the French colonisers. Some believe that the design bears French influence, that it is too symmetrical to be entirely African. That’s as may be, but what is clear is that over the following hundred years the mosque developed a different character. The building that the townspeople know is the result of a process more than a design. This is evident from the palm beams projecting from the walls. These are not architectural structure but social. People climb this scaffolding to renew both the building and themselves in an orgy of mud. They are the support structure of the annual rite.

How do the citizens of Djenné feel about this new, svelte form emerging from under the one they grew up with? And if we treat them as two separate images, which is the authentic one? The French colonial era mosque is angular, formal, rational. The “African” one is informal, organic, in keeping with the soft curves of the surrounding town. Ironically, since it lies on top of the original form, it seems inchoate, unformed rather than transformed, still in the process of being shaped. It has the quality of a model. As the 1906 building reappears, the building is regaining its sense of scale and detail. The AKTC is clearly saving the mosque, but in doing so it is erasing a contemporary building and reinstating an image from the past.

Of course, once the clock has been reset, the ritual feeding will resume. But the annual nourishment will not be the free-for-all of bygone years, it will be carefully supervised by the masons. The mud levels will be standardised. The terracotta ventilation flues on the roof now mark the limit with a two-inch high lip. In a sense the festival has been professionalised. Reason dictates that the Dionysian rite be moderated.