Nalanda's monastery is traditionally said to have been founded in the fifth century CE under the patronage of the Gupta emperor Kumaragupta I, in the ancient region of Magadha already closely associated with the Buddha's own life and teaching centuries earlier, and the site grew over succeeding reigns into a walled monastic complex of considerable size, supported by grants of land and revenue from a succession of Indian rulers including the later Pala dynasty.
By the seventh century, when the Chinese pilgrim monk Xuanzang studied and later taught there, Nalanda had become the preeminent center of Buddhist scholarship in Asia, housing, according to Xuanzang's own account, several thousand resident monks and students studying not only Buddhist philosophy and scripture but also Hindu philosophical schools, Sanskrit grammar, logic, medicine and astronomy, taught by a faculty of renowned scholars. The monastery maintained an extensive library complex known as the Dharmaganja, or Treasury of Truth, housed in several multistory buildings and reputed to hold hundreds of thousands of manuscripts covering both religious and secular subjects, making Nalanda as much a general university as a specifically religious institution in the modern sense. Its reputation drew students and pilgrim scholars from across Asia, including China, Korea, Tibet and Southeast Asia, several of whom, like Xuanzang and the later pilgrim Yijing, left detailed written accounts of the institution that remain primary sources for its history today.