The Muhammad Rahim Khan Madrasa, one of the biggest mosques in Khiva, was in front of the castle Kunya Arch. It was built by Sayyid Muhammad Rahim Khan (Madraim Khan II) in 1876. The building resembling the symmetric rectangle had a four-veranda yard with small towers in its angles.
The mosque corridor consisted of 8 exits with stairs to the cupolas. There was a restricted trade area with its warehouses at the entrance of the building. The Madrasa was a two-storey building, which had cupola shaped classrooms and accommodations.