In the subsequent years, Khvandamir worked as a munshi (secretary) and diplomat under Sultan Husayn Bayqara's oldest son and heir Badi' al-Zaman Mirza (died 1514), under whom he composed the Dastūr al-vuzarāʾ ("Exemplary viziers"), a biography list of pre-Islamic and Islamic viziers. Following the co-succession of Badi al-Zaman and his brother Muzaffar Husayn to the throne in 1506, Khvandamir was installed as one of the two sadrs (head of religious fundings) of the entire kingdom. Khvandamir retained his position following conquest of Herat by the Uzbek leader Muhammad Shaybani (died 1510), which led to the fall of the Timurids.
Over the following years, Khvandamir served as a munshi and diplomat under Sultan Husayn Bayqara's eldest son Badi' al-Zaman Mirza (who died in 1514). During this period, he authored "Dastūr al-vuzarāʾ," a biography of pre-Islamic and Islamic viziers. After the co-succession of Badi' al-Zaman and his brother Muzaffar Husayn to the throne in 1506, Khvandamir was appointed as one of two sadrs overseeing religious endowments for the kingdom. He continued in this role even after Muhammad Shaybani's conquest of Herat in 1510, which marked the decline of the Timurid dynasty.