The first documented mention of Khajuraho was made in 641 by Xuanzang, a Chinese pilgrim who described encountering several dozen inactive Buddhist monasteries and a dozen Hindu temples with a thousand worshipping brahmins. In 1022 CE, Khajuraho was mentioned by Abu Rihan-al-Biruni, the Persian historian who accompanied Mahmud of Ghazni in his raid of Kalinjar; he mentions Khajuraho as the capital of Jajahuti. The raid was unsuccessful, and a peace accord was reached when the Hindu king agreed to pay a ransom to Mahmud of Ghazni to end the attack and leave.