Formally part of the Ottoman Empire but essentially free from Ottoman control, starting in the 16th century Algiers turned to piracy and ransoming. Due to its location on the periphery of both the Ottoman and European economic spheres, and depending for its existence on a Mediterranean that was increasingly controlled by European shipping, backed by European navies, piracy became the primary economic activity. Repeated attempts were made by various nations to subdue the pirates that disturbed shipping in the western Mediterranean and engaged in slave raids as far north as Iceland. By the 17th century, up to 40% of the city's 100,000 inhabitants were enslaved Europeans. The United States fought two wars (the First and Second Barbary Wars) over Algiers' attacks on shipping.