In 788, about a century after the Arab conquest of North Africa, a series of Moroccan Muslim dynasties began to rule in Morocco.
In the 16th century, the Sa'adi monarchy, particularly under Ahmad al-MANSUR (1578-1603), repelled foreign invaders and inaugurated a golden age. The Alaouite dynasty, to which the current Moroccan royal family belongs, dates from the 17th century.
In 1860, Spain occupied northern Morocco and ushered in a half century of trade rivalry among European powers that saw Morocco's sovereignty steadily erode; in 1912, the French imposed a protectorate over the country.
A protracted independence struggle with France ended successfully in 1956. The internationalized city of Tangier and most Spanish possessions were turned over to the new country that same year.
Sultan MOHAMMED V, the current monarch's grandfather, organized the new state as a constitutional monarchy and in 1957 assumed the title of king.
Although Morocco is not the UN-recognized Administering Power for the Western Sahara, it exercises de facto administrative control there. The UN assists with direct negotiations between Morocco and the Polisario Front, but the status of the territory remains unresolved.
Gradual political reforms in the 1990s resulted in the establishment of a bicameral legislature, which first met in 1997.
Morocco enjoys a moderately free press, but the government has taken action against journalists who they perceive to be challenging the monarchy, Islam, or the status of Western Sahara.
Influenced by protests elsewhere in the region, in February 2011 thousands of Moroccans began weekly rallies in multiple cities across the country to demand greater democracy and end to government corruption.
Overall the response of Moroccan security forces was subdued compared to the violence elsewhere in the region. King MOHAMMED VI responded quickly with a reform program that included a new constitution and early elections.
The constitution was passed by popular referendum in July 2011; some new powers were extended to parliament and the prime minister, but ultimate authority remains in the hands of the monarch.
In early elections in November 2012, the Justice and Development Party — a moderate Islamist party, won the largest number of seats, becoming the first Islamist party to lead the Moroccan Government.
In January 2012, Morocco assumed a nonpermanent seat on the UN Security Council for the 2012-13 term.