The ancient al-Qarawiyyin Library in Fez isn’t just the oldest library in Africa. Founded in 859, it’s the oldest working library in the world, holding ancient manuscripts that date as far back as 12 centuries. But modern life had taken a toll on the library, with its buildings falling into disrepair. That’s why in 2012, the Moroccan Ministry of Culture asked TED Fellow and architect Aziza Chaouni to rehabilitate the library so that it can reopen to the general public. She describes the challenges inherent in undertaking a daunting, historic project. (Spoiler alert: she was successful; the library reopens in May 2016!)

First, some history. The al-Qarawiyyin Library was created by a woman, challenging commonly held assumptions about the contribution of women in Muslim civilization. The al-Qarawiyyin, which includes a mosque, library, and university, was founded by Fatima El-Fihriya, the daughter of a rich immigrant from al-Qayrawan (Tunisia today). Well educated and devout, she vowed to spend her entire inheritance on building a mosque and knowledge center for her community. According to UNESCO, the result is the oldest operational educational institution in the world, with a high-profile role call of alumni. Mystic poet and philosopher Ibn Al-‘Arabi studied there in the 12th century, historian and economist Ibn Khaldun attended in the 14th century, while in medieval times, Al-Qarawiyyin played a leading role in the transfer of knowledge between Muslims and Europeans.

The library’s deteriorating condition meant precious manuscripts were under threat from the elements. “When I first visited, I was shocked at the state of the place,” says Chaouni. “In rooms containing precious manuscripts dating back to the 7th century, the temperature and moisture were uncontrolled, and there were cracks in the ceiling.” At risk: ancient volumes covering centuries of knowledge in fields from theology to law, grammar to astronomy. While scholars have always had access to the materials, the library’s deteriorating condition meant it had long been closed to the public. In 2012, Kuwait’s Arab Bank provided a grant for cultural preservation to the Moroccan Ministry of Culture, who asked Chaouni not only to restore the buildings and protect the materials, but to open the library as a new public space.

Bringing a 1,157-year-old library up to date includes challenges — and surprises. Over the centuries, the library had been expanded via a hodgepodge of interconnected buildings, each one set on a different level of a steep hill. Chaouni’s job was to unify and upgrade them all to the same standard. “Throughout the years, the library underwent many rehabilitations, but it still suffered from major structural problems, a lack of insulation, and infrastructural deficiencies like a blocked drainage system, broken tiles, cracked wood beams, exposed electric wires, and so on,” says Chaouni of the practical architectural challenges she faced.

Meanwhile, restoring the ancient library while trying to respect its authenticity posed its own problems. For instance, how to find similar material to match missing or broken pieces of ancient zellige (mosaic) or cracked wooden railings and ceiling beams? Cleaning delicate plaster carvings without breaking them was hard, too. And the project was full of surprises: “One of the startling aspects about restoring a building this old is that you never know what’s behind a wall. You could scrap it and find a painting, take out the painting and find a door — and so on. We discovered some unexpected things, especially underground, such as a centuries-old sewage system.”

The trick: Restore the past and look to the future. While working hard to protect and preserve, Chaouni had to bring a sense of 21st-century pragmatism to the project. “I didn’t want the building to become an embalmed cadaver!” she says. “There has to be a fine balance between keeping the original spaces, addressing the needs of current users, including students, researchers and visitors, and integrating new sustainable technologies — solar panels, water collection for garden irrigation, and so on.” Another thing that needed updating: the library’s fountains. Embedded within the dense urban fabric of the UNESCO World Heritage Medina of Fez, fountains are part of the city’s vast and ancient water network. Chaouni took special care to restore the library’s original courtyard fountains, but where necessary, she created them from scratch, using local materials and construction systems, and introducing passive energy.

More than three years since the project broke ground, the library will open in May 2016. The public will be able to wander through a complex that includes a reading room, book stacks, a conference room, a manuscript restoration laboratory, and a rare books collection — along with new administrative offices and a café. Chaouni also commissioned furniture from local craftsmen who used native wood, and built courtyard umbrellas that provide shade and mist on hot summer days. Meanwhile, the 12th-century cupola will host permanent and temporary exhibition spaces. A proud, tired Chaouni is today adding important final touches, and looking forward to welcoming the library’s first guests. “Both Moroccans and foreign visitors will get to glimpse, for the first time, some of the library’s amazing and unique manuscripts, as well as to enjoy its architecture.”