The gate is located in the northern/northeastern corner of the city walls and dates back to around 1126 CE when the Almoravid emir Ali ibn Yusuf built the first walls of the city.[1][2] It was originally known as Bab Fes ("Gate of Fes"), but this name was apparently lost during the Marinid era.[1] The gate's current name (el-Khemis) refers to the souk or open-air market which historically took place here every Thursday (al-Khamis in Arabic).[3] Nowadays, the market continues almost all week right outside the gate[4], while a permanent flea market, Souk al-Khemis, has been constructed a few hundred meters to the north.[5][6] Also just outside the gate is a qubba (domed mausoleum) housing the tomb of a local marabout or Muslim saint.[4]