Just over a thousand years ago, someone sealed up a chamber in a cave outside the oasis town of Dunhuang, on the edge of the Gobi Desert in western China. The chamber was filled with more than five hundred cubic feet of bundled manuscripts. They sat there, hidden, for the next nine hundred years. When the room, which came to be known as the Dunhuang Library, was finally opened in 1900, it was hailed as one of the great archaeological discoveries of the twentieth century, on par with Tutankhamun’s tomb and the Dead Sea Scrolls.

The library was discovered by accident. In the early Middle Ages, Dunhuang had been a flourishing city-state. It had also long been famous as a center of Buddhist worship; pilgrims travelled great distances to visit its cave shrines, comprised of hundreds of lavishly decorated caverns carved into a cliff on the city’s outskirts. But by the early twentieth century, the town was a backwater, and its caves had fallen into disrepair. Wang Yuanlu, an itinerant Taoist monk, appointed himself their caretaker. One day, he noticed his cigarette smoke wafting toward the back wall of a large cave shrine. Curious, he knocked down the wall, and found a mountain of documents, piled almost ten feet high.

Although he couldn’t read the ancient scripts, Wang knew he had found something of incredible significance. He contacted local officials and offered to send the materials to the provincial capital; strapped for cash and preoccupied with the Boxer Rebellion, they refused. Soon, however, rumors of the discovery began to spread along the caravan routes of Xinjiang. One of the first to hear about it was the Hungarian-born Indologist and explorer Aurel Stein, who was then in the middle of his second archaeological expedition to Central Asia.

Stein rushed to Dunhuang, and, after waiting for two months, he finally met with Wang. Negotiations were delicate. Wang didn’t want to let any of the documents out of his sight, and was uneasy about selling them. Stein prevailed, eventually persuading the monk by invoking his patron saint, Xuanzang, a Chinese pilgrim who made an arduous journey to India in search of religious texts in the seventh century A.D. Claiming to be following in Xuanzang’s footsteps, Stein convinced Wang to sell him some ten thousand documents and painted scrolls for a hundred and thirty pounds.

News of the Dunhuang Library set off a manuscript race among the European powers. After Stein came Paul Pelliot, a brilliant, hotheaded French Sinologist who took some of the best items in Wang’s library after staying up nights reading through them at breakneck speed by candlelight, and others, including delegations from Russia and Japan. By 1910, when the Chinese government ordered the remaining documents to be transferred to Beijing, only about a fifth of the original hoard remained.

In the century since the Dunhuang Library was discovered, a whole academic discipline has sprung up around the materials it contained. It’s an extraordinarily demanding branch of study: the Library included documents in at least seventeen languages and twenty-four scripts, many of which have been extinct for centuries or known only from a few examples. The collection mirrors the remarkable diversity of Dunhuang itself, where Buddhists rubbed shoulders with Manicheans, Christians, Zoroastrians, and Jews, and Chinese scribes copied Tibetan prayers that had been translated from Sanskrit by Indian monks working for Turkish khans. Given how international the materials from Dunhuang are, scholars have agreed that the methods for their study should be, too. For decades, however, they have faced real problems, both in conducting research and in sharing their findings; Stein and the explorers who followed him scattered the library’s holdings among more than a dozen libraries and museums around the world.

But since 1994, an ambitious digitization program has slowly pushed the Dunhuang cache online, allowing scholars to reconstruct individual documents whose pages might be held by multiple collections, and to get a truer sense of its scope. Run by a team based in the British Library and working with partners in China, France, Germany, Japan, and Korea, the International Dunhuang Project is making the contents of the library available to experts worldwide, while simultaneously preserving them for future generations. Conservators in libraries from Paris to Tokyo have been restoring the ancient manuscripts and scanning them into an extensive, searchable database. In London, the work is conducted in a climate-controlled chamber several stories underground, where conservators first undo the work of previous generations, removing backings, frames, and patches. Then they encase the documents in a flexible polymer film called Melinex, which shields the fragments from the environment without causing warping or chemical leaching. Finally, they take high-resolution photographs of each document.

This work is painstaking: preserving the Diamond Sutra, a copy of a Chinese translation of one of the Buddha’s sermons, generally recognized as the oldest known example of a dated printed book, took over a thousand man-hours. But once completed, the restoration makes it possible to photograph the stabilized texts and digitize them at high fidelity. Armchair archive-divers can now examine the earliest complete star chart in the world, read a prayer written in Hebrew by a merchant on his way from Babylon to China, inspect a painting of a Christian saint in the guise of a bodhisattva, examine a contract drawn up for the sale of a slave girl to cover a silk trader’s debt, or page through a book on divination written in Turkic runes (if a boy finds eagle droppings, the omen is good; if an old ox is eaten by ants, it’s bad).

In addition to expanding access to ancient texts, the Dunhuang Project has opened new avenues for research. Historians at Beijing University have been using the digitized materials to chart the crucial ways in which China was shaped by foreign influence, especially from Iran. Other work has focussed on the collection’s neglected Tibetan holdings. By reassembling leaves of a sacred manuscript divided among several libraries, Jacob Dalton of the University of California at Berkeley has been able to reconstruct one of the earliest tantric manuscripts, which contains a startling, and seemingly very un-Buddhist, manual for performing human sacrifice.

The profusion of paper in Dunhuang also makes it a perfect place to study the development of this often overlooked technology. Paper was developed in China, originally as a wrapping material, and only gradually spread west, first to Central Asia, then to the Islamic world, before finally arriving in Europe in the fourteenth century. The library itself may owe its existence to the scarcity and preciousness of the material. Researchers from Japan and Britain have recently suggested that its manuscripts were offerings, donations left to honor the memory of a notable monk. When the little room that held them filled up, it was closed, and then forgotten.

The paper items preserved in the Library also shed light on the origins of another information technology: print. The Diamond Sutra, one of the most famous documents recovered from Dunhuang, was commissioned in 868 A.D., “for free distribution,” by a man named Wang Jie, who wanted to commemorate his parents. In the well-known sermon that it contains, the Buddha declares that the merit accrued from reading and reciting the sutra was worth more than a galaxy filled with jewels. In other words, reproducing scriptures, whether orally or on paper, was good for karma. Printing began as a form of prayer, the equivalent of turning a prayer wheel or slipping a note into the Western Wall in Jerusalem, but on an industrial scale.