The first inhabitants of Morocco were known to people outside the region as the Berbers. Today, however, the indigenous people refer to themselves as the Amazigh, which means "free." In the 12th century B.C., the Phoenicians established cities on the Mediterranean coast. Later, the Carthaginians occupied the cities, until they were defeated in the 2nd century B.C. by the Romans. The area became the Roman province of Mauretania Tiniagitana in 42 A.D. As Roman power weakened, the region became part of the Byzantine Empire. 
In 682 A.D., Arabs from the East brought Islam to Morocco and then to Spain. Thereafter, Muslim religious groups called dynasties ruled the country. The Idrissid Dynasty, which was founded in the 8th century, was succeeded by the Almoravids, the Almohads, the Merinids and the Saadians. The period of the Saadian Dynasty at the end of the 16th century is known as Morocco’s Golden Age. Under the Saadians, the country expanded to include a vast area from the Atlantic Ocean in the west to Egypt in the east and as far south as Timbuktu (now in Mali). The population swelled with Moors and Jews who had been forced to leave Spain. Arts and architecture flourished. In the middle of the 17th century the Alawite Sharifian Dynasty came to power. This dynasty has remained in power to the present day. 
  Did you know?
The capital city of Morocco has changed during its history. Under the Romans, it was Tignis (Tangier). Marrakesh was the capital between the 11th and 13th centuries, and again briefly in the 16th century. Fez was the capital from the 13th century to 1912, when it was moved to Rabat.
During the 19th century, European powers competed to control the countries of North Africa. The French, who occupied Algeria in 1830, extended their influence over Morocco, except for its Mediterranean coast, where the Spanish had an interest. In 1912, Morocco became a Protectorate of France, although the Spanish still controlled the north. 

The French dominated the economy. They built roads and railways and the port of Casablanca. Thousands of French people moved to Morocco. The Moroccans struggled to free themselves, and in 1925-26 the French sent troops to quell an uprising. After the Second World War, the Istiqlal (Independence) Party was formed. King Mohammed v, who supported independence, was exiled to Madagascar in 1953, but returned two years later. Finally, in 1956, France recognized Morocco’s independence, and soon afterwards, the Spanish gave up control of the north, except for Ceuta and Melilla. On May 8, 1958, Morocco was made a constitutional monarchy by Royal Charter.

Hassan II became king in 1961. During his reign, a new constitution was adopted by referendum. The King still retains the final decision-making power in all government matters. Starting in the mid-1970s, Morocco struggled to gain control over the West Sahara, a territory that had been dominated by Spain and was trying to establish itself as an independent country. A ceasefire was negotiated in 1991, but Morocco became politically isolated from other African countries. In 1999, Hassan II died at the age of 70 and was succeeded by his son, Mohammed Ibn Al Hassan.