The Karamanli or Caramanli or Qaramanli or al-Qaramanli dynasty or καραμανλή was a series of Pashas, who ruled from 1711 to 1835 in Tripolitania (Tripoli and its surroundings in present-day Libya). At their peak, the Karamanlis' influence reached Cyrenaica and Fezzan covering most of Libya. The founder of the dynasty was Pasha Ahmed Karamanli, a desecendent of the Karamanids . The most well-known Karamanli was Yusuf ibn Ali Karamanli Pasha who reigned from 1795 to 1832, who fought a war with the United States in (1801–1805) and again jointly with Tunis and Algiers in 1815. Ali II Pasha marked the end of the dynasty.
In the early eighteenth century, the Ottoman Empire was losing its grip on its North African holdings, including Tripolitania. A period of civil war ensued, with no ruler able to hold office for more than a year. Ahmed Karamanli, a Janissary and popular cavalry officer, murdered the Ottoman governor of Tripolitania and seized the throne in the 1711 Karamanli coup. After persuading the Ottomans to recognize him as governor, Ahmed established himself as pasha and made his post hereditary. Though Tripolitania continued to pay nominal tribute to the Ottoman padishah, it otherwise acted as an independent kingdom.
An intelligent and able man, Ahmed greatly expanded his city's economy, particularly through the employment of corsairs on crucial Mediterranean shipping routes; nations that wished to protect their ships from the corsairs were forced to pay tribute to the pasha. On land, Ahmed expanded Tripolitania 's control as far as Fezzan and Cyrenaica before his 1745 death.
Ahmad's successors proved to be less capable than himself, preventing the state from ever achieving the brief golden ages of its Barbary neighbors, such as Algiers or Tunis. However, the region's delicate balance of power allowed the Karamanli to survive several dynastic crises without invasion.
In 1793, Turkish officer Ali Benghul deposed Hamet Karamanli and briefly restored Tripolitania to Ottoman rule. However, Hamet's brother Yusuf (r. 1795-1832) returned to Tripolitania and with the aid of the bey of Tunis, reestablished Tripolitania's independence.
In 1801, Yusuf demanded a tribute of $225,000 from United States President Thomas Jefferson. Jefferson, confident in the ability of the new United States Navy to protect American shipping, refused the Pasha's demands, leading the Pasha to unofficially declare war, in May 1801, by chopping down the flagpole before the American consulate. Jefferson responded by ordering the US Navy into the Mediterranean, successfully blockading Tripolitania's harbors in 1803. After some initial military successes, most notably the capture of the USS Philadelphia, the pasha soon found himself threatened with invasion by American ground forces following the Battle of Derna and the reinstatement of his deposed brother, Hamet Karamanli, recruited by the American army officer William Eaton. He signed a treaty ending the war on June 10, 1805.
By 1819, the various treaties of the Napoleonic Wars had forced the Barbary states to give up piracy almost entirely, and Tripolitania's economy began to crumble.  Yusuf attempted to compensate for lost revenue by encouraging the trans-Saharan slave trade, but with abolitionist sentiment on the rise in Europe and to a lesser degree the United States, this failed to salvage Tripolitania's economy. As Yusuf weakened, factions sprung up around his three sons; though Yusuf abdicated in 1832 in favor of his son Ali II, civil war soon resulted. Ottoman Sultan Mahmud II sent in troops ostensibly to restore order, but instead deposed and exiled Ali II, marking the end of both the Karamanli dynasty and an independent Tripolitania.  A descendant family with the same name still exists in modern Tripoli-Libya.
List of Rulers of the Karamanli (Caramanli) Dynasty (1711-1835)
- Ahmad I Pasha (29 July 1711 - 4 November 1745)
- Mehmed Pasha (4 November 1745 - 24 July 1754)
- Ali I Pasha (24 July 1754 - 30 July 1793)
- Ali (II) Burghul Pasha Cezayrli (30 July 1793 - 20 January 1795) (usurper)
- Ahmad II Pasha (20 January - 11 June 1795)
- Yusuf Pasha (11 June 1795 - 20 August 1832)
- Mehmed (1817) (1st time, in rebellion)
- Mehmed ibn 'Ali (1824) (1st time, in rebellion)
- Mehmed (1826) (2nd time, in rebellion)
- Mehmed (July 1832) (3rd time, in rebellion)
- Mehmed ibn 'Ali (1835) (2nd time, in rebellion)
- Ali II Pasha (20 August 1832 - 26 May 1835)
- Hume, L. J. "Preparations for Civil War in Tripoli in the 1820s: Ali Karamanli, Hassuna D'Ghies and Jeremy Bentham." The Journal of African History 21.3 (1980): 311-322.
- McLachlan, K. S. "Tripoli and Tripolitania: Conflict and Cohesion during the Period of the Barbary Corsairs (1551-1850)." Transactions of the Institute of British Geographers, New Series 3.3 (1978): 285-294.