This story originally appeared in the July/August 2016 issue of mental_floss magazine.

On Friday morning, January 25, 2013, 15 jihadis entered the restoration and conservation rooms on the ground floor of the Ahmed Baba Institute in Sankoré, a government library in Mali. The men swept 4,202 manuscripts off lab tables and shelves and carried them into the tiled courtyard. They doused the manuscripts—including 14th- and 15th-century works of physics, chemistry, and mathematics, their fragile pages covered with algebraic formulas, charts of the heavens, and molecular diagrams—in gasoline. Then they tossed in a lit match. The brittle pages and their dry leather covers ignited in a flash.

In minutes, the work of Timbuktu’s greatest savants and scientists, preserved for centuries, hidden from the 19th-century jihadis and French conquerors, survivors of floods, bacteria, water, and insects, were consumed by the inferno.

In the capital city of Bamako 800 miles away, the founder of Timbuktu’s Mamma Haidara Library, a scholar and community leader named Abdel Kader Haidara, saw the burning of the manuscripts as a tragedy—and a vindication of a remarkable plan he’d undertaken. Starting with no money besides the meager sum in his savings account, the librarian had recruited a loyal circle of volunteers, badgered and shamed the international community into funding the scheme, raised $1 million, and hired hundreds of amateur smugglers in Timbuktu and beyond. Their goal? Save books.

Months earlier, Haidara had been pacing the courtyard at his home, pondering how to respond to the rebels’ seizure of Timbuktu. Largely thanks to Haidara, the city now had 45 libraries, ranging from small private archives to 10,000-volume collections. The libraries served as repositories for a total of 377,000 manuscripts—from 400-hundred-page, leather-encased volumes to single folios—including some of the greatest works of medieval literature in the world. And now Al Qaeda was putting it all in jeopardy.

The extremists had declared jihad against anything that challenged their vision of a pure Islamic society, and these artifacts—treatises about logic, astrology, and medicine, paeans to music, poems idealizing romantic love—represented 500 years of human joy. Jihadi spokesmen had appeared on radio and television twice soon after their capture of Timbuktu to reassure people that “we won’t harm the manuscripts.” But Haidara and most of his friends and colleagues dismissed the promise as a public relations ploy.

A few days after the occupation began, Haidara met with his colleagues at the office of Savama-DCI, the Timbuktu library association he had formed 15 years earlier. “What do we have to do?” Haidara asked them. “What do you think we have to do?” a colleague replied. “I think we need to take out the manuscripts from the big buildings and disperse them around the city to family houses. We don’t want them finding the collections of manuscripts and stealing them or destroying them.”

Months earlier, the Ford Foundation office in Lagos, Nigeria, had given Haidara a $12,000 grant to study English at Oxford University in the fall and winter of 2012 to 2013. The money had been wired to a savings account in Bamako. He emailed the foundation and asked for authorization to reallocate the funds to protect the manuscripts from the hands of Timbuktu’s occupiers. The money was released in three days.

Haidara recruited his nephew Mohammed Touré, who had worked with Haidara at the library since he was 12. Touré and his uncle reached out to people they trusted—archivists, secretaries, Timbuktu tour guides, and half a dozen of Haidara’s nephews and cousins. The volunteers went from shop to shop in Timbuktu’s commercial district, buying between 50 and 80 metal trunks a day as discreetly as possible. When the metal lockers were sold out, they bought lesser-quality ones in wood. When they had purchased every trunk in Timbuktu, they swept through markets in the riverside town of Mopti. When they had bought up every one in Mopti, they purchased oil barrels in Timbuktu and shipped them down to Mopti workshops. Metalworkers broke the barrels, refashioned them into chests, and sent them back downriver to Timbuktu.

In one month, they accumulated 2,500 trunks and moved them into storage rooms inside the city’s libraries to prepare for the evacuation.

One evening in late April, Haidara, Touré, and several other volunteers met in front of the Mamma Haidara Library and began the dangerous task of moving the manuscripts. They had waited until after dark—when they could work inside the library without attracting the scrutiny of the Islamic Police.

Carrying two trunks, the men moved silently across the courtyard, entered the main building, and locked the doors behind them. The rebels had cut the electricity in Timbuktu, obliging the librarians to use flashlights—only one or two to avoid drawing attention. Whispering among themselves in the darkness, and guided by the night watchman, they opened the cases in the main exhibition hall and delicately removed the volumes displayed inside. They groped their way down hallways and worked methodically in the conservation labs and library shelves where the bulk of the manuscripts were held. Keeping close track of the time, they limited themselves to two hours, packing in as much as they could, often in silence, listening for every suspicious sound. The manuscripts ranged from miniature volumes to large, encyclopedia-sized works, and required artful arranging, in near-total darkness, to maximize space. Because of the speed with which the volunteers were forced to work and the shortage of funding, they used no cushioning, no cardboard boxes, and no humidity traps to protect from potential damage.

When they had finished packing, they sealed the chests with padlocks, locked the door of the library behind them, and hurried home down shadowy alleys, keeping a sharp eye out for Islamic Police patrols. The following evening, they returned to the library, picked up the lockers, wrapped them in blankets, and loaded them onto mule carts, which took them to private safe houses in the city. Haidara told nobody outside his fellow librarians what he was doing—not even his immediate family.

Haidara wanted to keep the manuscripts in Timbuktu. But in the summer of 2012, the jihadis there went on a rampage, destroying a dozen Sufi shrines. In August, Libyan Wahhabis, known as Najdis, outdid their Timbuktu counterparts. They desecrated dozens of graves in a Sufi cemetery in Tripoli’s Old City, knocked down a mausoleum in Misrata and three in Tripoli, bulldozed and blew up the shrine of a 15th-century Sufi scholar in the Mediterranean coastal town of Zlitan, and fired mortar rounds at the mosque and library of Al Asmari University in the same city. The shells ignited a fire inside the library that burned thousands of manuscripts to ashes. The safe houses no longer felt safe. Haidara recalled, “I knew we didn’t have much time.” He decided to transport the manuscripts to Bamako, 606 miles to the south.

But moving hundreds of thousands of priceless and fragile artifacts over unpredictable terrain would be dangerous and hugely expensive. Haidara knew he would need to hire couriers and drivers and rent hundreds of trucks, four-wheel-drive vehicles, and taxis. Additionally, they’d need cash for bribes, spare parts, repairs, and gasoline. Emily Brady, a scholar from Washington state who had become captivated by Haidara’s collection during a visit to Mali in the 1990s, calculated a budget of $700,000. They reached out to contacts around the world. Haidara secured $100,000 from one of his most generous benefactors: Dubai’s Juma Al Majid Center. A grant of $135,000 from the Prince Claus Fund in the Netherlands also came through. A Kickstarter campaign raised another $60,000. The Dutch National Lottery, one of the richest cultural foundations in the Netherlands, wired $255,000.

Meanwhile, in Timbuktu, Touré cast about for sturdy four-wheel-drive vehicles and recruited drivers and couriers. The majority were teenagers, the sons and nephews of Timbuktu’s librarians—people whose loyalty would remain unquestioned.

At dawn one morning in late August, Touré and a driver parked a Land Cruiser in front of a safe house in Timbuktu and loaded it with five chests filled with 1,500 manuscripts from the Mamma Haidara Library. Each chest was four feet long by two feet wide and two feet deep, and could snugly fit up to eight stacks of manuscripts. He draped a blanket over the footlockers, and climbed in the Land Cruiser beside the driver. A chill desert wind blew as they pulled away from the safe house and, beneath a brightening sky, drove south, past the Islamic Police headquarters in the former Commercial Bank of Mali. The turbaned fighters who manned the first checkpoint on the southern outskirts of Timbuktu waved him through. They passed the municipal airport and there the tarmac ended. He crossed the Niger River by car ferry and then for several hours drove on the sand track south, through an undulating landscape of dried-out riverbeds and faint patches of grass, scattered acacias, and scrub.

The vehicle reached Konna, beside the Niger, a town of mud huts, labyrinthine alleyways, and a small mosque modeled after the Great Mud Mosque of Djenné. Konna marked the start of Malian government territory. Touré called Haidara on his cell phone and informed him with relief that he was now in the zone of safety. Then, just south of the line of control, his illusions of safety dissolved. Malian troops—edgy, demoralized, and suspicious of anyone coming from the occupied north—stopped him at Sévaré.

They pointed rifles at his chest and ordered him out. “Remove the trunks.” One by one, Touré and his driver pulled the manuscript-filled chests out of the rear compartment.

The soldiers smashed the locks on the chests with their gun butts, pulled out the volumes, and flipped roughly through the fragile pages. Touré kept silent as he watched them manhandle the precious volumes.

For two days and nights they kept him and his driver under guard in a spartan camp beside the roadblock, feeding him but refusing to explain why they were detaining him. At last, they told him he could go. In the riverside town of Ségou, Touré hit another military checkpoint marked by four-foot-high metal oil drums strewn across the road. “What’s this? What are you doing? What are you smuggling?” the soldiers demanded. As Touré watched helplessly, they broke the locks for the second time, and rifled through the manuscripts one by one.

When Touré reached Bamako’s Porte d’Entrée, where the military searched every vehicle entering the capital, Touré was detained again. Exhausted and hungry, he was taken to a camp, thrown into a filthy cell, given nothing to eat or drink, and interrogated. Touré was permitted one phone call, to Haidara, who arrived at dawn with tea and bread, ate with him in his cell, and freed him with a “gift” to his jailers.

It had been a terrible ordeal that had lasted a week, yet no sooner had Touré delivered his cargo to safe havens in Bamako than he returned to Timbuktu and prepared for the next journey. Touré would make more than 30 round-trips between Timbuktu and Bamako, personally saving tens of thousands of manuscripts.

Every day, sometimes five times a day, Haidara traveled to the Porte d’Entrée, on Bamako’s northern outskirts. Lengthy negotiations—and the invariable payment of “gifts”—allowed his hundreds of couriers to slip through. Some returned to Bamako so shaken that they dropped out after a single mission, but most remained committed to the end. During the first 90 days, Haidara’s couriers evacuated about 270,000 of the 377,000 manuscripts, nearly three-quarters of the books that had been held in the city’s safe houses. But that July, Haidara’s evacuation plan ground to a halt.

War had broken out across the north. The French military had intervened and stopped the jihadis from capturing Bamako and declaring all of Mali a caliphate. The manuscripts were at risk from both Al Qaeda, who seemed likely to lash out at anything that the West considered valuable, and from the French military, which had turned the entire north into a zone of gunfire and destruction. A total of 791 footlockers containing 100,000 manuscripts remained trapped in safe houses in Timbuktu. Desperate, Haidara was obliged to consider the only viable alternative to the road: the Niger River.

Haidara’s team recruited dozens of local boatmen and laid out the rules: Their destination would be Djenné, on the floodplain between the Niger and the Bani Rivers, 223 miles and two days south of Timbuktu. Once the footlockers had been unloaded safely in government territory, trucks, taxis, and other vehicles would receive the cargo and continue the journey to Bamako, 332 miles further south.

A lone vessel left on a test run. The 30-foot boat motored down the center of the river. Then, with alarm, the couriers and captains heard an engine and the whir of rotor blades. A French attack helicopter swooped down low over the water and hovered above the craft. “Open the footlockers,” they demanded over a loudspeaker. The French warned the crew that they would sink the boat on suspicion of smuggling weapons if the couriers refused. The terrified teenage couriers flung the chests open and stepped aside. The pilots could see that the chests were filled with only paper and flew off.

Shortly afterward, 20 vessels, each carrying 15 metal chests filled with manuscripts, motored in a convoy down the Niger from a port near Timbuktu. As the convoy threaded its way along channels through the grass, a dozen turbaned men brandishing Kalashnikovs emerged from the dense vegetation. They were bandits and ordered the flotilla to stop. Forcing the couriers to open the locks, the men thumbed through the Arabic texts. “We will keep these,” they announced.

The couriers pleaded with them and offered their cheap Casio watches, silver bracelets, rings, and necklaces. When that failed, they called Haidara, in Bamako. He urged the bandits to release the couriers and the cargo, promising to deliver a sizeable ransom.

Haidara couldn’t afford not to pay them, he would later explain: Thousands of other manuscripts were already heading downriver. The couriers waited nervously while the bandits debated what to do. At last, the gunmen released the boats and the manuscripts. One of Haidara’s agents, as promised, delivered the cash four days later.

In Bamako, Haidara spent 15 hours a day talking simultaneously on eight cell phones to his team of couriers, whom he had instructed to brief him every 15 minutes when they were on the road. Huge sheets of brown butcher paper taped to one wall tracked the names of the teenagers, their latest cell phone contacts, the number of footlockers each was carrying, their locations, and conditions en route. Text messages were sent to donors informing them of progress: 75 footlockers going through, our kids have made it across lake débo, are now in mopti. During one frenetic day toward the end of the boatlift, 150 taxicabs, each carrying three footlockers and a courier, made the journey from Djenné to Bamako.

In a low-tech operation that seemed quaint in the second decade of the 21st century, Haidara and his team had transported to safety, by river and by road, past hostile jihadi guards and suspicious Malian soldiers, past bandits, attack helicopters, and other lethal obstacles, almost all of Timbuktu’s 377,000 manuscripts. Not one had been lost en route. “Abdel Kader and I experienced something I have trouble describing. Power, strength, perseverance can’t adequately articulate what it was,” Brady said in an interview on Reddit. “We kept thinking that we had to lose some manuscripts—theft, bandits, belligerents … combat, books in canoes on the Niger River—we had to lose some, right? Well, we didn’t. Not a single manuscript was compromised during the evacuation—nada, zero. They all made it.”

From The Bad-Ass Librarians of Timbuktu: And Their Race to Save the World’s Most Precious Manuscripts, by Joshua Hammer. Copyright © 2016 by Joshua Hammer. Reprinted by permission of Simon & Schuster, Inc.