Dunhuang manuscripts refer to a wide variety of religious and secular documents (mostly manuscripts, but also including some woodblock-printed texts) in Chinese and other languages that were discovered at the Mogao Caves of Dunhuang, China, during the 20th century. The majority of the surviving texts come from a large cache of documents produced between the late 4th and early 11th centuries which had been sealed in the so-called ' Library Cave' (Cave 17) at some point in the early 11th century. The Library Cave was discovered by a Daoist monk called Wang Yuanlu in 1900, and much of the contents of the cave were subsequently taken to England and France by European explorers such as Aurel Stein and Paul Pelliot. Knowing that the Dunhuang manuscripts were priceless treasures, Stein and Pelliot swindled Wang and bought them for very little money. They took the majority of these treasures from China to Europe.
In addition to the Library Cave, manuscripts and printed texts have also been discovered in several other caves at the site. Notably, Pelliot retrieved a large number of documents from Caves 464 and 465 in the northern section of the Mogao Caves. These documents mostly date to the Yuan dynasty (1271–1368), several hundred years after the Library Cave was sealed, and are written in various languages, including Chinese, Tibetan, and Old Uyghur. 
The Dunhuang documents include works ranging from history and mathematics to folk songs and dance. There are also many religious documents, most of which are Buddhist, but other religions including Daoism, Nestorian Christianity, Judaism, and Manichaeism are also represented. The majority of the manuscripts are in Chinese. Other languages represented are Khotanese, Kuchean, Sanskrit, Sogdian, Tibetan, Old Uyghur language, Prakrit, Hebrew, and Old Turkic.  The manuscripts are a major resource for academic studies in a wide variety of fields including history, religious studies, linguistics, and manuscript studies. 
The majority of surviving Dunhuang manuscripts were kept in a cave, the so-called Library Cave (Cave 17), which had been walled off sometime early in the 11th century. The documents in the cave were discovered by the Daoist monk Wang Yuanlu, who was interested in restoring the Mogao Caves, on June 25, 1900.  In the next few years, Wang took some manuscripts to show to various officials who expressed varying level of interest, but in 1904 Wang re-sealed the cave following an order by the governor of Gansu concerned about the cost of transporting these documents. From 1907 onwards, Wang began to sell them to Western explorers, notably Aurel Stein and Paul Pelliot. According to Stein who was the first to describe the cave in its original state:
Heaped up in layers, but without any order, there appeared in the dim light of the priest's little lamp a solid mass of manuscript bundles rising to a height of nearly ten feet, and filling, as subsequent measurement showed, close on 500 cubic feet. The area left clear within the room was just sufficient for two people to stand in. 
Stein had the first pick and he was able to collect around 7,000 complete manuscripts and 6,000 fragments for which he paid £130, although these include many duplicate copies of the Diamond and Lotus Sutras. Pelliot took almost 10,000 documents for the equivalent of £90, but, unlike Stein, Pelliot was a trained sinologist literate in Chinese, and he was allowed to examine the manuscripts freely, so he was able to pick a better selection of documents than Stein. Pelliot was interested in the more unusual and exotic of the Dunhuang manuscripts, such as those dealing with the administration and financing of the monastery and associated lay men's groups. Many of these manuscripts survived only because they formed a type of palimpsest whereby papers were reused and Buddhist texts were written on the opposite side of the paper. Hundreds more of the manuscripts were sold by Wang to Ōtani Kōzui and Sergey Oldenburg.  
In addition to the manuscripts that he acquired from Wang, Pelliot also uncovered a large number of manuscripts and printed texts from Caves 464 and 465 (Pelliot's Caves 181 and 182) in the northern section of the site. These documents date to the Yuan dynasty (1271–1368), and are written in various languages, including Chinese, Tibetan, and Old Uyghur. The documents also include over two hundred fragments of texts written in the Tangut language, which is significant as the Tangut script (devised in 1036) is entirely absent from the Library Cave documents. 
Scholars in Beijing were alerted to the significance of the manuscripts after seeing samples of the documents in Pelliot's possession. Due to the efforts of the scholar and antiquarian Luo Zhenyu, most of the remaining Chinese manuscripts were taken to Beijing in 1910 and are now in the National Library of China. Several thousands of folios of Tibetan manuscripts were left in Dunhuang and are now located in several museums and libraries in the region.  Rumours of caches of documents taken by local people continued for some time, and a cache of documents hidden by Wang from the authorities was later found in the 1940s.  Those purchased by Western scholars are now kept in institutions all over the world, such as the British Library and the Bibliothèque nationale de France. All of the manuscript collections are being digitized by the International Dunhuang Project, and can be freely accessed online.
“The Chinese regard Stein and Pelliot as robbers,” wrote the British sinologist Arthur Waley. “I think the best way to understand [the feelings of the Chinese] on the subject is to imagine how we should feel if a Chinese archaeologist were to come to England, discover a cache of medieval manuscripts at a ruined monastery, bribe the custodian to part with them and carry them off to Peking. [...] Pelliot did, of course, after his return from Tun-huang, get in touch with Chinese scholars; but he had inherited so much of the nineteenth-century attitude about the right of Europeans to carry off ‘finds’ made in non-European lands that, like Stein, he seems never from the first to last to have had any qualms about the sacking of the Tun-huang library.” 
While most studies use Dunhuang manuscripts to address issues in areas such as history and religious studies, some have addressed questions about the provenance and materiality of the manuscripts themselves. Various reasons have been suggested for the placing of the manuscripts in the library cave and its sealing. Aurel Stein suggested that the manuscripts were "sacred waste", an explanation that found favour with later scholars including Fujieda Akira.  More recently, it has been suggested that the cave functioned as a storeroom for a Buddhist monastic library,  though this has been disputed.  Reasons for this include the fact that, according to Rong and Hansen (1999) there was an organized method to the manner in which many manuscripts in the caves were placed; “Buddhist texts that had been divided into sections, labeled, and then placed in wrapped bundles." 
The reason for the cave's sealing has also been the subject of speculation. A popular hypothesis, first suggest by Paul Pelliot, is that the cave was sealed to protect the manuscripts at the advent of an invasion by the Xixia army, and later scholars followed with the alternative suggestion that it was sealed in fear of an invasion by Islamic Kharkhanids that never occurred.  Even though cave 16 could easily have been enlarged or extended to cave 17, Yoshiro Imaeda has suggested cave 16 was sealed because it ran out of room. 
The variety of languages and scripts found among the Dunhuang manuscripts is a result of the multicultural nature of the region in the first millennium AD.  The largest proportion of the manuscripts are written in Chinese, both Classical and, to a lesser extent, vernacular Chinese. Most manuscripts, including Buddhist texts, are written in Kaishu or 'regular script', while others are written in the cursive Xingshu or 'running script'. An unusual feature of the Dunhuang manuscripts dating from the 9th and 10th centuries is that some appear to have been written with a hard stylus rather than with a brush. According to Akira Fujieda this was due to the lack of materials for constructing brushes in Dunhuang after the Tibetan occupation in the late 8th century. 
The Dunhuang manuscripts represent some of the earliest examples of Tibetan writing. Several styles are represented among the manuscripts, forebears of the later Uchen (dbu can) and Ume (dbu med) styles.  Both Old Tibetan and Classical Tibetan are represented in the manuscripts, as well as the undeciphered Nam language and a language that some have identified as the Zhangzhung language.
By far the largest proportion of manuscripts from the Dunhuang cave contain Buddhist texts. These include Buddhist sutras, commentaries and treatises, often copied for the purpose of generating religious merit.  Several hundred manuscripts have been identified as notes taken by students,  including the popular Buddhist narratives known as bian wen (變文).  Much of the scholarship on the Chinese Buddhist manuscripts has been on the Chan (or Zen) texts, which have revolutionized the history of Chan Buddhism.  Among the Tibetan Buddhist manuscripts, the texts of early Tibetan tantric Buddhism, including Mahayoga and Atiyoga or Dzogchen have been the subject of many studies. 
This section needs additional citations for verification. (June 2017)