The Berbers were the first people to settle in what is now Morocco. There was no central authority in this area; instead, people lived in large, extended-family-based tribes. Rather, Berbers in each tribe followed the mandates of their chiefs, who might set standards that were radically different from those of other tribes.
As a result, Morocco was repeatedly invaded in its formative years due to a lack of centralized government. Starting in the 12th century B.C., the Phoenicians were the initial aggressors. As a result of their success in taking over coastal settlements, the Carthaginians eventually returned the favor. In the 2nd century B.C., the Romans launched a massive campaign against the Carthaginians and succeeded in capturing and converting all of their strongholds in the region. The Roman Empire eventually collapsed, paving the way for Arab conquest. The country was left reeling and generally unstable after brief but intense battles for control between Arabs and Jews. During his dynasty, however, a man named Ahmed I al-Man-sur was able to bring stability to the country. Because of the influx of Jews and Moors from Spain, Morocco flourished between 1579 and 1603. They all contributed something to the artistic and cultural landscape of modern-day Morocco.
When fighting broke out between the Spanish and Portuguese in the early 15th century, the Port of Cueta ultimately fell under Portuguese control in 1415. The Moroccans, however, rose up against the Portuguese in 1578 and took back the port. The battle sparked a nationwide uprising that ended with the Moroccans retaking virtually all of the coastal towns that had been ruled by Portugal. In 1904, France and Spain divided Morocco, with France getting the larger portion. In 1911, Germany dispatched a gunboat to the French-held coast of Morocco in an attempt to seize territory. Thankfully, war was avoided after the French and Germans reached an agreement in which the French would retain control of Morocco in exchange for concessions from the Germans in other areas.
The then-sultan of Morocco sought independence in 1950. The answer to their initial plea was negative. Sultan Mohammed ascended to the throne in 1957. This paved the way for independence, and Spain quickly gave up most of its holdings in Morocco afterward.
King Hassan launched an extensive campaign in 1974 to regain the Spanish-held portions of the Sahara. The ICJ ruled against Morocco's bid to assume full sovereignty over the Sahara. King Hassan, however, was a persistent man, and he continued onwards. Spain and Morocco reached an agreement after months of behind-the-scenes talks. Morocco, Spain, and Mauritania all claim a portion of the Sahara Desert, but historically the region was divided in three. Although Mauritania was expelled from the Sahara by the Polisaro front in 1978, Morocco remained unmoved. The UN facilitated a referendum on self-determination for the parties involved, and while the results were generally accepted, Morocco has persisted in its efforts to gain control of the entire Sahara.