By the end of the Middle Ages, Turkey—which was under the Ottoman Dynasty —had become the greatest power in the Muslim world. As the fifteenth century came to a close, the Turks conquered Constantinople (now Istanbul), capital of what was left of the eastern Roman Empire. Turkish power stretched around the Mediterranean world, from Greece and southeastern Europe to the northwestern coast of Africa.
The city of Algiers became part of the Ottoman Empire, in name, in 1518, when Khair al Din, a Muslim from the Greek islands, seized the city. To deal with challenges from the Spanish and to consolidate his power, he gave his allegiance to the Turkish sultan. The sultan, in turn, appointed Khair al Din commander and regent, or ruler in his name, of Algiers and gave him Turkish troops to help sustain his power. Similar military leaders took power with Turkish support in other coastal cities.
For three hundred years, the cities in the region known as the Barbary Coast (from "Berber") by Europeans were ruled by military leaders who acknowledged the sultan. In reality, however, these leaders became largely independent of the Turks. Their coastal cities devoted themselves to piracy, seizing goods and taking travelers as slaves. Many European countries paid the Barbary States of Algiers, Tunis, Tripoli, and Morocco to allow their ships to pass through the Mediterranean. After the United States became independent from Great Britain at the end of the eighteenth century, the Americans also found it necessary to pay the North African pirate cities.
In 1815, after the end of Europe's Napoleonic Wars, several European countries declared war on Algiers, one of the most aggressive of the Barbary States. The United States sent a naval force that year and had the rulers of Algiers and Tunis sign treaties agreeing to stop interfering with American trade and to pay damages to the Americans. The following year the British and Dutch sent a fleet to Algiers and forced the ruler, known as the dey, to honor his treaty with the Americans and to sign a new treaty with them. From that time until the late twentieth century, northwestern Africa was dominated by Europeans.