Erica Eisen at the LRB:
The Library Cave was bricked up some time in the 11th century, for unknown reasons: perhaps to keep the books safe from invaders; or perhaps, given the large number of worn and partial texts, the chamber was less a library than a tomb for books. Locals continued to worship at the shrines, but several of the the exterior walkways connecting the ancient cave entrances collapsed, and the sand that slowly filled many of the caves severely abraded their delicate murals.
At the end of the 19th century, Wang Yuanlu, a Taoist monk, took it on himself to restore the caves. He found the cache of texts in the course of his repairwork, and in 1907 sold the Dunhuang Diamond Sūtra, along with more than 9000 other objects, to the Hungarian-British archaeologist Aurel Stein, who smuggled them out of the country. Earlier plans by Chinese officials to take the library’s collection out of the caves for storage and scholarly analysis had been put on hold for lack of funds; in China, Stein is widely regarded as a thief. The sūtra remains in England, housed in the British Library.
more here.