The history of Western Sahara can be traced back to the times of Carthaginian explorer Hanno the Navigator in the 5th century BC. Though few historical records are left from that period, Western Sahara's modern history has its roots linked to some nomadic groups (living under Berber tribal rule and in contact with the Roman Empire) such as the Sanhaja group, and the introduction of Islam and the Arabic language at the end of the 8th century AD.
Western Sahara has never been a nation in the modern sense of the word. It was home to Phoenician colonies, but those disappeared with virtually no trace. Islam arrived there in the 8th century, but the region, beset with desertification, remained little developed.
From the 11th to the 19th centuries, Western Sahara was one of the links between the sub-Saharan and North African regions. During the 11th century, the Sanhaja tribal confederation allied with the Lamtuna tribe to found the Almoravid dynasty. The conquests of the Almoravids extended over present-day Morocco, Western Algeria, and the Iberian Peninsula to the north and Mauritania and Mali to the south, reaching the Ghana Empire. By the 16th century, the Arab Saadi dynasty conquered the Songhai Empire based on the Niger River. Some Trans-Saharan trade routes also traversed Western Sahara.
In 1884, Spain claimed a protectorate over the coast from Cape Bojador to Cape Blanc, and the area was later extended. In 1958, Spain combined separate districts together to form the province of Spanish Sahara.
A 1975 advisory opinion by the International Court of Justice on the status of the Western Sahara held that while some of the region's tribes had historical ties to Morocco, they were insufficient to establish "any tie of territorial sovereignty" between the Western Sahara and the Kingdom of Morocco. In November of that year, the Green March into Western Sahara began when 300,000 unarmed Moroccans, accompanied by the Moroccan Army armed with heavy weapons, converged on the southern city of Tarfaya and waited for a signal from King Hassan II of Morocco to cross into Western Sahara.