While at the Samanid court, he compiled his best-known work, Mafātīḥ al-ʿulūm [The Keys of the Sciences], an early Islamic encyclopedia of the sciences, intended as a reference work for court officials. It was produced at the request of Abū l-Ḥasan al-ʿUtbī a vizier in the court of Amir, Nuh II.[5] and the work is dedicated to al-Utbi which establishes a date for its completion of around 977.[6] In Nishapur, Al-Khwarizmi wrote a number of rihla (short, humorous accounts of a journey; partly written in verse and partly in literary prose), of which only fragments survive.[7] Locally, he achieved great fame as a leading scholar and writer. However, his reputation was eclipsed following the arrival of an aspiring young scholar and writer, Badi' al-Zaman al-Hamadani in 383/992.