The Beylik of Tunis (بايليك تونس), also known as Kingdom of Tunis (المملكة التونسية) was a largely autonomous beylik of the Ottoman Empire located in present-day Tunisia. It was ruled by the Husainid dynasty from 1705 until the establishment of the French protectorate of Tunisia in 1881. The term beylik refers to the monarch, who was called the Bey of Tunis. Under the protectorate, the institution of the Beylik was retained nominally, with the Husainids remaining as largely symbolic sovereigns.
The Beys remained faithful to the Sublime Porte, but reigned as monarchs after gradually gaining independence from the Ottoman Empire. Between 1861 and 1864, the Beylik of Tunis became a constitutional monarchy after adopting the first constitution in Africa and the Arab world. The country had its own currency and an independent army, and in 1831 it adopted its flag, which is still in use today.
The institution of the Beylik was finally abolished one year after independence on 25 July, 1957 when the republic was declared.
Following the Revolutions of Tunis which saw Ibrahim Sharif overthrow Muradids' power, the latter became the first bey to combine this function with that of Pasha. Taken to Algiers following a defeat against the Dey of Algiers, and unable to put an end to the troubles which agitated the country, he was a victim, on 10 July 1705 of a coup of Al-Husayn I ibn Ali, who took the name of Hussein I.
Hussein I reigned alone over Tunisia, establishing a real monarchy and became Possessor of the Kingdom of Tunis, disposing over all his subjects the right of high and low justice. His decrees and decisions had the force of law.
As Bey of Tunis he sought to be perceived as a popular Muslim interested in local issues and prosperity. He appointed as qadi a Tunisian Maliki jurist, instead of an Hanafi preferred by the Ottomans. He also restricted the legal prerogatives of the janissary and the Dey. Under Hussein I, support was provided to agriculture, especially planting olive orchards. Public works were undertaken, e.g.