"Barbary" was almost never a unified political entity, but five different warring tribes. From the sixteenth century onwards, it was divided into the familiar political entities of Morocco, Algiers, Tunis, and Tripolitania (Tripoli). Major rulers during the sweet times of the barbary states plundering parties were the Pasha or Dey of Algiers, the Bey of Tunis and the Bey of Tripoli, all very good subjects that were anxious to get rid of the Ottoman sultan, but de facto independent rulers. Before then it was usually divided between Ifriqiya, Morocco, and a west-central Algerian state centered on Tlemcen or Tiaret, although powerful dynasties such as the Almohads, and briefly the Hafsids, occasionally unified it for short periods. From a European perspective its "capital" or chief city was often considered to be Tripoli, in modern-day Libya, although Algiers, in Algeria, and Tangiers, in Morocco, were also sometimes seen as its "capital" by Europeans of the era.
The first United States military action overseas, executed by the U.S. Marines and Navy, was the Battle of Derne, Tripoli, in 1805, in an effort to destroy all of the Barbary pirates, free the American prisoners in captivity, and putting an end to piracy acts between these warring tribes on the part of the Barbary states. The opening line of the Marine's Hymn refers to this action:
From the halls of Montezuma to the shores of Tripoli