In a mud-and-brick town that blends in with the rusty red sand of the vast Sahara, generations of families have been guarding ancient books—some perhaps 1,000 years old—and with them, the reputation of a once-legendary, enlightened city. These libraries—mostly simple, mud-packed shelves stacked high with bound manuscripts in ancient huts—are what remain of a place that in better times was the epicenter of Islamic learning and medieval trading in northern Africa. In Mauritania, Chinguetti once flourished with scholars, pilgrims, and religious leaders. But today, the few thousand people left have been fighting against the harsh desert to maintain control of their precious artifacts.‬

The remaining 10 or so libraries hold frayed remains of ancient books on Quranic studies, science, and law. They’re tended to by the same families who’ve been passing down their literary treasures for generations. Some hold just a few shelves and boxes of manuscripts, but one contains an organized collection of 1,400 texts.

Actor and explorer Michael Palin, visiting in 2001, described one elderly bookkeeper showing off his priceless wares. “In some cases the pages have come loose from their bindings, but in all of them the quality of the work is exquisite. They have been in his family for centuries and he treats the texts like old friends, moving his finger from right to left, as the Chinese and Japanese do, across the delicate, spidery calligraphy.”‬

Chinguetti was founded in the 12th century to serve as a resting point for the Saharan trade routes crisscrossing present-day Morocco, Mauritania, and Mali. Desert caravans would use the city as an oasis, stopping to peddle their wares and let the thousands of camels in their trains rest. Since the 13th century, Sunni devotes have been traveling to Chinguetti on their way to Mecca. A stone mosque built not long after the city became a well-trodden passageway still stands as a central attraction in the town. What was once just a stopover point quickly became a destination in its own right. As the small city’s reputation flourished, particularly between the 1600s and 1800s, it became known as a pillar of religious scholarship and was considered one of Islam’s holiest cities.‬

But the desert has been creeping up on Chinguetti. Half a century ago, there were said to be 30 libraries and 20,000 inhabitants. Today, only as many as 10 book troves remain and the population numbers a couple thousand. In the 1970s, new mines constructed nearby pulled away the town’s inhabitants, and, soon after, the 16-year Western Sahara War broke out, forcing more Chinguettis from their homes near the border of the disputed region. Around that same time, the United Nations Conference on Desertification announced that the Sahara was expanding at an estimated rate of 30 miles per year due to rising temperatures.‬

UNESCO granted Chinguetti and four other nearby trading posts status as World Heritage sites in 1996. Despite the international protection that designation affords, the city is succumbing to one of the most inhospitable landscapes in the world. Chinguetti’s location was once chosen for its fertility in the middle of the African desert. But now, it is surrounded by rolling red dunes, and blowing sand coats the city.‬

Just as the town’s population is in danger, so too are the town’s fragile books. A preservation survey UNESCO organized in the ’90s found that there were 3,450 volumes left in Chinguetti, but that 90 percent of them were in advanced stages of decay thanks to climate damage and mishandling.‬

The government of Mauritania, from the capital 375 miles away, has been attempting to preserve the delicate manuscripts, but keepers of the books have been wary to part with them. According to The Guardian, 33,000 ancient texts are known to exist in the country, but only a couple thousand have been properly cleaned and archived in the National Museum.‬

“The state has been trying to lay its hands on them for years,” one keeper of a 700 book-strong library told the paper. “Would you part with your hand or your foot? It is a part of us.”‬‬