The Beylik of Tunis was founded on July 15, 1705, after the Husainid Dynasty led by Al-Husayn I ibn Ali at-Turki defeated the Turkish Deys.
Although defeating the Deys, Tunisia continued to be a vassal of the Ottoman Empire and the Friday prayer was pronounced in the name of the Ottoman Sultan, money was coined in his honour, and an annual ambassador brought gifts to Constantinople but the Ottomans never again exacted obedience.
In the 19th century, the country became mostly autonomous, although it was still officially an Ottoman province. In 1861, Tunisia enacted the first constitution in the Arab world, but a move toward independence was hampered by the poor economy and political unrest. In 1869, Tunisia declared itself bankrupt, and an international financial commission with representatives from France, United Kingdom, and Italy took control over the economy.