Home to some of the world’s most important medieval Quranic texts, this desert oasis was once an intellectual hub. But after more than 1,200 years, it may soon vanish.

Rising like a mirage on the edge of Mauritania’s vast Erg Warane sand dunes, the ancient city of Chinguetti has welcomed travellers seeking shelter from the blistering Saharan heat for more than 1,200 years. Founded in the 8th Century as a caravan stop for pilgrims en route to Mecca, this red-stone desert oasis eventually blossomed into one of the biggest centres of science, religion and mathematics in West Africa.

As pilgrims and scholars came and went, many left religious texts, scientific studies and historical manuscripts. In fact, so many of these historical documents accumulated over the years that during Chinguetti’s peak between the 13th and 17th Centuries, this thriving city boasted 30 libraries.

Today, five of these original libraries remain and a team of loyal custodians humbly guards more than 1,000 priceless medieval Quranic manuscripts from the sand, wind and heat. But as the Sahara continues to expand southward at an alarmingly fast rate and encroach on Chinguetti’s flat-roofed buildings, and with climate change recently causing seasonal flash flooding to rip through the town, the future of these Islamic treasures remains in jeopardy.

This video is part of BBC Reel’s Incredible Libraries playlist.

Join more than three million BBC Travel fans by liking us on Facebook, or follow us on Twitter and Instagram.

If you liked this story, sign up for the weekly bbc.com features newsletter called "The Essential List". A handpicked selection of stories from BBC Future, Culture, Worklife and Travel, delivered to your inbox every Friday.