In 2012, jihadists—armed to the teeth with weapons seized in Libya after the fall of Muammar Qaddafi—overran northern Mali and established a brutal, sharia regime in Timbuktu. Once a center of learning and culture, the city housed a priceless collection of manuscripts: volumes of poetry, encyclopedias, and even sexual manuals that invoked the name of Allah. Threatened with destruction, the manuscripts were spirited out of the city to safety in a thrilling, cloak-and-dagger operation.

View Images Courtesy of Simon & Schuster

Speaking from his home in Berlin, Joshua Hammer, a former Newsweek bureau chief in Africa, recounts the tale of The Bad-Ass Librarians of Timbuktu: And Their Race to Save the World’s Most Precious Manuscripts—and explains how the Timbuktu manuscripts disprove the myth that Africa had no literary or historical culture, why Henry Louis Gates had an epiphany when he saw them, and why the jihadists found them so threatening.

Timbuktu has become a byword for the farthest corner of the earth. But it was once an important cultural and artistic center. Put us on the ground during its golden age.

Several of the great travelers of the Renaissance, in the 15th-16th centuries, passed through Timbuktu and described it as a thriving commercial center with camel caravans and traders on boats on the Niger River bearing everything from linens and teapots from England to slaves and gold out of the rain forests of Central Africa. At the same time, you had this academic tradition. So you had a thriving commercial center side by side with a Cambridge/Oxford-like atmosphere of fervent scholastic activity.

Al Qaeda in the Islamic Magreb swept to power in Mali. Talk about its rise—and its fanatical leader, Abou Zeid.

Abou Zeid was one of a triumvirate of jihadists, probably the most brutal of them, who took over northern Mali between January and April in 2012. Another leader was Mokhtar Belmokhtar, an Algerian jihadist who had been hardened fighting in Afghanistan and fallen in with some of the most notorious international jihadists. He was also a cigarette smuggler, who made millions by dominating the cigarette trade across the Sahara up into North Africa. This earned him the nickname “Mister Marlboro.”

In the chaos of the uprising against Qaddafi, the jihadists raided the armories of Libya, took the weapons into Mali, and quickly swept across the northern part of the country, occupying all of the major towns in the north, including Timbuktu. They imposed sharia law and began to destroy every symbol of moderate Sufi Islam that almost all residents of modern Timbuktu subscribe to. Shrines to Sufi saints were destroyed; whippings and amputations were carried out in the public squares of the city; and, of course, the manuscripts were threatened.

View Images In its heyday during the 15th and 16th centuries, Timbuktu was a commercial center boasting 50,000 residents, a flourishing literary culture, and a tolerant brand of Islam. Photograph by Brent Stirton, National Geographic

The manuscripts were not kept in an archive, but by individual families. Explain this unusual provenance—and how it helped preserve them.

Timbuktu was a university town during its golden age. Many of the universities were operated out of mosques, so you had a lot of books and manuscripts being created for the scholars. At the same time, you had these wealthy families that valued learning. Because it had this long scholastic tradition, Timbuktu also had a great literary tradition: powerful Timbuktu families measuring their importance by the books they accumulated on Greek philosophy, poetry, love stories, guides to better sex, astronomy, traditional medicine, as well as the religious books. They would be copied by scribes and accumulated both in the universities and in private homes. So huge libraries were created, numbering in the thousands of volumes. Nobody knows how many manuscripts were in the city at its peak but it was almost certainly in the hundreds of thousands.

The hero of your book is a man named Abdel Kader Haidara. Give us a character sketch and describe his extraordinary efforts to collect the manuscripts together.

Abdel Kader Haidara is the son of a scholar from Timbuktu. His father ran an Islamic school in the oldest quarter of Timbuktu. So Abdel Kader grew up around these manuscripts. When he was 17, his father died. He had a dozen brothers and sisters but in the will his father made him the heir to the family book collection, which numbered in the thousands at that time. His father appreciated Abdel Kader’s scholarship and studiousness. He was also fluent in Arabic, which was essential if you were going to be in charge of these manuscripts as they were almost all written in Arabic.

A few years later, the curator for the national library in Timbuktu called on Abdel Kader and asked him if he would take on a job, traveling around the countryside visiting villages and nomadic encampments, trying to track down some of the ancient manuscripts that had been disbursed into the desert. Timbuktu was conquered by the Moroccans in the 1590s and a lot of the books were spirited out of the city. Abdel Kader reluctantly took on the job—he wanted to be a businessman rather than a scholar working in a library—and began trudging around the countryside in camel caravans or taking boats along the Niger, trying to persuade these villagers to give up their precious family heirlooms and turn them all over to this national library in Timbuktu.

He proved to be incredibly successful at this and also found that he loved the job. He built the national library into a great institution and turned his own family’s collection into a library in Timbuktu, raised money, and got other librarians involved. By the year 2000, Timbuktu had become a cultural boomtown that had recaptured some of the glory of its heyday in the 16th century, when it was the scholastic center of North Africa. He found manuscripts stashed away in dark storage rooms or caves in the desert. By the time of the jihadi invasion of 2012, he had assembled a collection of 377,000 manuscripts.

View Images Almost 400,000 ancient manuscripts—some dating back to the 11th century and on subjects as diverse as medicine, poetry, astronomy, and sex—were saved from destruction. Photograph by Brent Stirton, Getty Images/National Geographic

You call the manuscripts “monumentally subversive.” Explain.

Because they posited a worldview that was anathema to the jihadists. There were celebrations of music, which the Salafist fundamentalists do not tolerate, and books about sex in which the reader was asked to invoke the name of Allah as a way of heightening his sexual prowess. Abdel Kader especially valued these things because they showed a more tolerant side of Islam.

Henry Louis Gates came to Timbuktu to see the manuscripts in 1996. Why was the experience such an epiphany for him?

Henry Louis Gates came to Timbuktu when he was a professor at Harvard and also making documentaries about African civilization. He’d grown up with the idea that Africans were savages. He recalled a Ripley’s Believe It or Not cartoon he’d seen as a small boy, which said that there had been libraries and universities in Timbuktu. When he finally got to Harvard and began making documentaries, one of the first things he wanted to do was go up to Timbuktu and tell the story of these universities to try to refute the cliché that Africans had no history or intellectual traditions. The argument was that blacks were inferior to Europeans because they had no written language. In Timbuktu, Gates went to see Abdel Kader Haidara, fell in love with the manuscripts, and ended up going back to the U.S. and raising almost $100,000 for Haidara to open the first private library in the city.

View Images French military officers sit with the mayor of Timbuktu, Dravi Mega, on January 28, 2013. Photograph by Noel Quidu, Paris Match/Getty Images

The final rescue of the manuscripts by river to the capital, Bamako, was an amazing cloak-and-dagger operation. Set the scene for us.

There were three stages of the operation. The first was after Abdel Kader became concerned that the jihadists might target the manuscripts. So they moved them out of the big libraries of Timbuktu into safe houses around the city. They did it at night, putting the manuscripts in boxes and moving them by donkey cart to people’s basements and storage rooms. In the second phase, a couple of months later, they moved them out of the city by vehicle: one vehicle after another, in constant motion, often escorted by teenage couriers, over 600 miles of desert, passing through checkpoints and bluffing their way all the way to Bamako, the capital in the south.

The third phase, after the French Army invaded and it became too dangerous to move the books by road, involved taking them by boat up the Niger River toward Bamako, then offloading them from the boats and putting them into taxis. It was an elaborate and dangerous process that went on for months, right under the noses of the jihadists.

View Images Tuareg nomads allied with the jihadists in the hope of achieving independence. Here, they celebrate the end of the Ramadan fast in the desert outside Timbuktu with prayer and dancing. Photograph by Brent Stirton, Getty Images/National Geographic

The French were called “cheese-eating surrender monkeys” by proponents of the Iraq War. But their prompt and decisive military action in Mali rather disproved that moniker, didn’t it?

There was no way the U.S. was going to go to war in Mali. There was no oil [laughs], and it was Francophone territory. So Obama was delighted when President Hollande announced he was going to send troops in, after the jihadists overreached and tried to take over the rest of the country.

The showdown came at a place called Ametettai. A Foreign Legion officer, Captain Oudot de Danville, led a group of hardened paratroopers into battle. They traveled over many miles in the high desert of Mali to Ametettai, where they fought a fight to the finish against the jihadists, who were hunkered down inside caves in this very rocky, arid, brutally hot valley. There were also regular French and Chadian forces, who are really hardened badasses, as well. And they were able to pretty much wipe out the jihadists in one week of fighting.

View Images The manuscripts were smuggled across 600 miles (965 kilometers) of desert to Bamako, the capital of Mali. Here, a camel caravan laden with salt approaches Timbuktu. Photograph by Brent Stirton, Getty Images/National Geographic

You end the story in 2014, with the manuscripts still stored in Bamako. What's the current situation? And will they ever go back to Timbuktu?

Who knows? The manuscripts have all been collected in one large storage facility in Bamako, so they have been brought together under one roof. They are being digitized and those that were damaged in the course of the smuggling operation are being carefully restored. Meanwhile, Abdel Kader is keeping an eye on the situation in Timbuktu. He would love to take them back but he doesn’t think the time is right. I’m not really sure when that time will be. It’s already been three years, and I don’t think there’s any end in sight to this purgatory. Last November, there was an attack on the Radisson Hotel in Bamako, so the jihadists are infiltrating the southern part of the country, which they were never able to do at the height of their occupation in the north. I don’t think they will ever again be able to mount a major operation to seize territory. But they’re still out there.

This interview was edited for length and clarity.