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 town in the area, making them effectively a single city. The name "Riyadh," meaning "gardens" refers to these earlier oasis towns.
Third Saudi State
In 1744, Muhammad ibn Abdel Wahhab formed an alliance with Muhammad ibn Saud, the ruler of the nearby town of Diriyah. Ibn Saud then set out to conquer the surrounding region with the goal of bringing it under the rule of a single Islamic state. Ibn Dawwas of Riyadh led the most determined resistance, allied with forces from Al Kharj, Al Ahsa, and the Banu Yam clan of Najran. However, Ibn Dawwas fled and Riyadh capitulated to the Saudis in 1774, ending long years of wars, and leading to the declaration of the First Saudi State, with Diriyah as its capital.
The First Saudi State was destroyed by forces sent by Muhammad Ali of Egypt, acting on behalf of the Ottoman Empire. Ottoman forces razed the Saudi capital Diriyah in 1818. They had maintained a garrison at Najd. This marked the decline of the House of Saud for a short time. Turki bin Abdullah bin Muhammad became the first Amir of the Second Saudi State; the cousin of Saud bin Saud, he ruled for 19 years till 1834, leading to the consolidation of the area though they were notionally under the control of the Muhammad Ali, the Viceroy of Egypt. In 1823, Turki ibn Abdallah chose Riyadh as the new capital. Following the assassination of Turki in 1834, his eldest son Faisal killed the assassin and took control, and refused to be controlled by the Viceroy of Egypt. Najd was then invaded and Faisal taken captive and held in Cairo. However, as Egypt became independent of the Ottoman Empire, Faisal escaped after five years of incarceration, returned to Najd and resumed his reign, ruled till 1865, and consolidated the reign of House of Saud.
Following the death of Faisal, there was rivalry among his sons which situation was exploited by Muhammad bin Rashid who took most of Najd, signed a treaty with the Ottomans and also captured Hasa in 1871. In 1889, Abdul Rahman bin Faisal, the third son of Faisal again regained control over Najd and ruled till 1891, whereafter the control was regained by Muhammad bin Raschid.
Internecine struggles between Turki's grandsons led to the fall of the Second Saudi State in 1891 at the hand of the rival Al Rashid clan, which ruled from the northern city of Ha'il. The al-Masmak fort dates from that period.
Abdul Rahman bin Faisal al-Saud had sought refuge among a tribal community on the outskirts of Najd and then went to Kuwait with his family and stayed in exile. However, his son Abdul Aziz retrieved his ancestral kingdom of Najd in 1902 and consolidated his rule by 1926, and further expanded his kingdom to cover "most of the Arabian Peninsula." He named his kingdom as Saudi Arabia in September 1932 with Riyadh as the capital. King Abdul Aziz died in 1953 and his son Saud took control as per the established succession rule of father to son from the time Muhammad bin Saud had established the Saud rule in 1744. However, this established line of succession was broken when King Saud was succeeded by his brother King Faisal in 1964. In 1975, Faisal was succeeded by his brother King Khalid. In 1982, King Fahd took the reins from his brother. This new line of succession is among the sons of King Abdul Aziz who has 35 sons; this large family of Ibn Saud hold all key positions in the large kingdom.
From the 1940s, Riyadh "mushroomed" from a relatively narrow, spatially isolated town into a spacious metropolis. When King Saud came to power, he made it his objective to modernize Riyadh, and began developing Annasriyyah, the royal residential district, in 1950. Following the example of American cities, new settlements and entire neighbourhoods were created in grid-like squares of a chess board and connected by high-performance main roads to the inner areas. The grid pattern in the city was introduced in 1953. The population growth of the town from 1974-1992 averaged 8.2 percent per year.
The current mayor of Riyadh is Ibrahim Mohammed Al Sultan, an experienced transport official. He was appointed mayor in 2015. Riyadh is now the administrative, and to a great extent the commercial hub of the Kingdom. According to the Saudi Real Estate Companion, most large companies in the country establish either sole headquarters or a large office in the city. For this reason, there has been a significant growth in high rise developments in all areas of the city. Most notable among these is King Abdullah Financial District which is fast becoming the key business hub in the city. Riyadh also has the largest all-female university in the world, the Princess Nora bint Abdul Rahman University.
According to the Global Financial Centres Index, Riyadh ranked at 77 in 2016-2017. Though the rank moved up to 69 in 2018, diversification in the economy of the capital is required in order to avoid what the World Bank called a "looming poverty crisis" brought on by lingering low oil prices and rich state benefits.
Since 2017, Riyadh has been the target of missiles from Yemen. In March 2018, one person died as a result of a missile attack. The number of missiles which targeted Riyadh are a small portion of the dozens of missiles fired from Yemen at Saudi Arabia due to the Saudi Arabian-led intervention in Yemen. In April 2018, heavy gunfire was heard in Khozama; this led to rumors of a coup attempt.