In 840 AD, the Samanid chief of Samarkand Nūḥ ibn Asad, wrested control of the city from the Turks. In that year, Nūḥ built a wall around it to protect it from the Turks. By this time the city was a flourishing market center at the nexus of nomad and sedentary lands. It was also a linchpin in the broad zone of protective forts built to protect the Samanid empire from nomadic raiders. Moqaddasi numbered these fortresses, or "ribāṭ"s, at 1,700. They built outer walls to protect the crops of the inhabitants from raiders, but the town was not only a military outpost. Traders from Bukhara and Samarkand constructed large caravanserais for themselves in Sayram.