structural:reformatting, stylistic:tone
Early history

During the Pre-Islamic era, the city at the site of modern Riyadh was called Hajr (Arabic: حجر), and was reportedly founded by the tribe of Banu Hanifa. Hajr served as the capital of the province of Al-Yamamah, whose governors were responsible for most of central and eastern Arabia during the Umayyad and Abbasid eras. Al-Yamamah broke away from the Abbasid Empire in 866 and the area fell under the rule of the Ukhaydhirites, who moved the capital from Hajr to nearby Al-Kharj. The city then went into a long period of decline. In the 14th century, North African traveler Ibn Battuta wrote of his visit to Hajr, describing it as "the main city of Al-Yamamah, and its name is Hajr ". Ibn Battuta goes on to describe it as a city of canals and trees with most of its inhabitants belonging to the Bani Hanifa, and reports that he continued on with their leader to Mecca to perform the Hajj.

Later on, Hajr broke up into several separate settlements and estates. The most notable of these were Migrin (or Muqrin) and Mi'kal, though the name Hajr continued to appear in local folk poetry. The earliest known reference to the area by the name Riyadh comes from a 17th-century chronicler reporting on an event from the year 1590. In 1737, Deham ibn Dawwas, a refugee from neighboring Manfuha, took control of Riyadh. Ibn Dawwas built a single wall to encircle the various oasis towns in the area, making them effectively a single fortress city. The name "Riyadh", meaning "gardens" refers to these earlier oasis towns.