Originally, the madrasah was built as a caravan-sarai. However, at the opening ceremony Imamkuli-khan (1611-1642) following the advice of Sufi sheikhs had congratulated his minister with successful completion of the construction “in the honor of Allah” and suddenly named the building a madrasah.