By the middle of the 7th century, the Muslim empire extended from the Arabian Peninsula north to what is today's east Afghanistan, southern Turkmenistan, Iran, Iraq, Syria and Egypt, and west to northern Libya. Diverse ethnic groups came to be part of one empire, ruled by Arabs from Mecca.
New ethnic groups embraced the new faith, but some still felt uneasy about being ruled by people they had long perceived as inferior. So they set out to preserve their identity and culture, sparking a trend that still has reverberations across ethnic relations and state politics in the Middle East today.
The concept of "shu'ubiyya" - a categorisational term from the Arabic word for "people" or "nations" - rejected Arab hegemony within the empire and separated Arabs as a race from Islam as a religion. The trend was first limited to racial bias against Arabs, often citing support from religious texts, but later attained social, intellectual and political dimensions.
After the Arab revolts that swept the region last year, the Sunni-Shia rift widened to worrying levels as different countries and peoples in the region chose sides based on sectarian lines in the popular protests in Bahrain and Syria, the sectarian strife in Lebanon, and Iraq's political crisis. The same sectarian sentiments are now creeping slowly into other countries, including Egypt and beyond. These increasing communal tensions are one of the products of the 2003 war in Iraq and the sectarian violence that followed, but they are also rooted in history.
Shu'ubiyya emerged first among Persians within the Muslim community in the 7th century, and deepened with the revival of Arab tribalism during the Umayyad caliphate (661-750). Before the Umayyads, the sense of tribalism among Arabs had weakened because Islam required loyalty to the nation rather than the tribe. But the Umayyads allied themselves with certain tribes to support their dynastic rule, leading to the revival of Arab tribal pride and a widening distinction between Arabs and Muslims of other ethnicities.
By conferring privileges to some tribes but not others, the Umayyad rulers weakened the sense among less advantaged groups of belonging to a nation, ultimately undermining the Arab hegemony within the empire and giving rise to ethnic rivalries.
Towards the end of the Umayyad reign, with the unrest that pervaded the region at the time, non-Arab ethnic groups began to assert their presence and identity. Shu'ubiyya then evolved from racial stereotyping into a set of ideas about Islamic leadership and whether leadership should be exclusive to Arabs. It was then maintained that righteousness and contributions to Islam - not ethnicity - would determine merit.
The trend took root during the Abbasid caliphate (750-1258) with increased technocratic and scientific contributions by Persians throughout what is known as the Golden Age of Arabic science (800-1100). During the 16th century, shu'ubiyya further deepened when the Safavids ruled Iran. Safavid rulers made Shia Islam the religion of the state, fought against the Sunni Ottomans and sought to purge Iran of Sunni influence.
By then, shu'ubiyya had taken a new tack: many Sunni Arabs came to view Iran as a hostile neighbour in terms of both ethnicity and sectarianism. Religious affiliation became amalgamated with ethnic identity, a problematic manifestation of shu'ubiyya that deepened religious differences. This tendency is virulent today and fuels divisions between Arabs and Iranians and, by extension, between Arab Shiites and Sunnis.
These sentiments were clear after Egypt's President Mohammed Morsi's visit to Tehran last week during the Non-Aligned Movement summit. Mr Morsi began his speech by saluting the two caliphs, Abu Bakr and Omar, the first and second rulers after Prophet Mohammed. Shiites view them as illegitimate leaders, while Sunnis consider them to be companions of the Prophet who must be emulated. Sunni clerics heralded the speech as a "victory" over the "enemy number one in its own house".
The reaction to Mr Morsi's speech is a symptom of communal tensions that plague the region. It is common, for example, for Arab Shiites to be labelled as "Safawi", from Safavids, implying they are Iranian lackeys. Some clerics also cite a saying attributed to an early Muslim leader: "How I wish that there was a mountain of fire between us and them [Persians]. They would not reach us and we would not reach them."
Sectarian sentiments in the region are widespread and add to existing divisions. At the Islamic summit in Mecca last month, Saudi Arabia proposed a centre for dialogue between different Islamic religious strands. The idea came amid rising sectarian sentiments, arguably the worst in a century, stoked by extremists on both sides and exploited for political ends.
But the schism is not merely a question of religious differences. It is founded in social and political mistrust. Religious dialogue without addressing the issues that breed division is not the answer. Indeed in 2004, 200 Muslim scholars from 50 countries issued a landmark statement recognising eight Islamic schools of jurisprudence, including three Shia ones - without making any palpable difference.
Serious efforts on the part of politicians and civil societies are needed to counter these sentiments, from outreach campaigns to criminal charges against figures who stoke sectarianism. While many may consider sectarianism as a politically expedient form of demagoguery, the consequences are dangerous.
On Twitter: @hhassan140