Inhabited since the Paleolithic Era over 90,000 years ago, the first Moroccan state was established by Idris I in 788. It was subsequently ruled by a series of independent dynasties, reaching its zenith as a regional power in the 11th and 12th centuries, under the Almoravid and Almohad dynasties, when it controlled most of the Iberian Peninsula and the Maghreb. In the 15th and 16th centuries, Morocco faced external threats to its sovereignty, with Portugal seizing some territory and the Ottoman Empire encroaching from the east. The Marinid and Saadi dynasties otherwise resisted foreign domination, and Morocco was the only North African nation to escape Ottoman dominion. The Alaouite dynasty, which rules the country to this day, seized power in 1631, and over the next two centuries expanded diplomatic and commercial relations with the Western world. Morocco's strategic location near the mouth of the Mediterranean drew renewed European interest; in 1912, France and Spain divided the country into respective protectorates, reserving an international zone in Tangier. Following intermittent riots and revolts against colonial rule, in 1956 Morocco regained its independence and reunified.  