During the 17th and 18th centuries, Morocco was one of the Barbary States, the headquarters of pirates who pillaged Mediterranean traders. European powers showed interest in colonizing the country beginning in 1840, and there were frequent clashes with the French and Spanish. Finally, in 1904, France and Spain concluded a secret agreement that divided Morocco into zones of French and Spanish influence, with France controlling almost all of Morocco and Spain controlling the small southwest portion, which became known as Spanish Sahara. Morocco grew into an even greater object of European rivalry by the turn of the century, almost leading to a European war in 1905 when Germany attempted to gain a foothold in the mineral-rich country. By the terms of the Algeciras Conference (1906), the sultan of Morocco maintained control of his lands and France's privileges were curtailed. The conference was an indication of what was to come in World War I, with Germany and Austria-Hungary lining up on one side of the territorial dispute, and France, Britain, and the United States on the other.