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.
Morocco has capitalized on its proximity to Europe and relatively low labor costs to build a diverse, open, market-oriented economy. In the 1980s Morocco was a heavily indebted country before pursuing austerity measures and pro-market reforms, overseen by the IMF. Since taking the throne in 1999, King MOHAMMED VI has presided over a stable economy marked by steady growth, low inflation, and gradually falling unemployment, although a poor harvest and economic difficulties in Europe contributed to an economic slowdown in 2012. Industrial development strategies and infrastructure improvements - most visibly illustrated by a new port and free trade zone near Tangier - are improving Morocco's competitiveness. Morocco also seeks to expand its renewable energy capacity with a goal of making renewable 40% of electricity output by 2020. Key sectors of the economy include agriculture, tourism, phosphates, textiles, apparel, and subcomponents. To boost exports, Morocco entered into a bilateral Free Trade Agreement with the United States in 2006 and an Advanced Status agreement with the European Union in 2008. Despite Morocco's economic progress, the country suffers from high unemployment, poverty, and illiteracy, particularly in rural areas. In 2011 and 2012, high prices on fuel - which is subsidized and almost entirely imported - strained the government''s budget and widened the country''s current account deficit. Key economic challenges for Morocco include fighting corruption and reforming the education system, the judiciary, and the government''s costly subsidy program.