Tunisian nationality law (; French: Code de la nationalité tunisienne) is regulated by the Constitution of Tunisia, as amended; the Tunisian Nationality Code, and its revisions; and various international agreements to which the country is a signatory. These laws determine who is, or is eligible to be, a national of Tunisia. The legal means to acquire nationality, formal legal membership in a nation, differ from the domestic relationship of rights and obligations between a national and the nation, known as citizenship. Nationality describes the relationship of an individual to the state under international law, whereas citizenship is the domestic relationship of an individual within the nation. Tunisian nationality is typically obtained under the principal of jus sanguinis, i.e. by birth in Tunisia or abroad to parents with Tunisian nationality. It can be granted to persons with an affiliation to the country, or to a permanent resident who has lived in the country for a given period of time through naturalization.

Acquisition of nationality Nationality can be acquired in Tunisia at birth or later in life through naturalization.

By birth Those who acquire nationality at birth include:

Children born in Tunisia who have a father and paternal grandfather also born in Tunisia; Children born anywhere to a Tunisian father or mother acquire nationality automatically; Children born in Tunisia with unknown nationality or who would be otherwise stateless; or Foundlings or orphans, whose parents are unknown.

By naturalization Naturalization can be granted to persons who have resided in the territory for a sufficient period of time to confirm they understand Arabic, the customs and traditions of Tunisia, and are integrated into the society. General provisions are that applicants have good character and morals; have no criminal convictions which resulted in sentencing in excess of one year; are in sufficient mental and physical health to avoid becoming a dependent of the state; and have a principal interest in the development of Tunisia. Applicants must typically have resided in the country for five years. Besides foreigners meeting the criteria, other persons who may be naturalized include:

Children legally adopted by a Tunisian parent automatically acquire nationality at the time of completion of a legal adoption; Children can be automatically naturalized when their father acquires nationality, or if their mother is a widow and becomes naturalized; Persons born in Tunisia may opt for nationality without completing a residency requirement; The wife of a Tunisian national upon marriage may acquire Tunisian nationality after a two-year residency, or immediately if she is or will become stateless because of the marriage; or Persons who have performed exceptional service to the nation may naturalize without a residency period.

Loss of nationality Tunisian nationals may not renounce their nationality. There is a conflict of laws since passage of the 2014 Constitution which in Article 25 states that no Tunisian can be deprived of their nationality, exiled, extradited, or prevented from returning to Tunisia. () Terms of the Nationality Code provide that persons may be denaturalized in Tunisia for working for a foreign state or military without permission of Tunisian authorities; disloyalty to the state; committing crimes against the state or state security; for ordinary serious crimes; or for fraud, misrepresentation, or concealment in a naturalization petition. Naturalized persons may also lose their nationality for failure to complete military service in Tunisia.

Dual nationality Tunisian law has allowed dual nationality in most cases since 1975. Dual nationality is forbidden for the President of Tunisia.

History The earliest populations known in the territory of what is now Tunisia were Berber peoples. Though various empires, including Phoenicia, Rome, and Byzantium incorporated their territory, the Berbers refused to assimilate with these outside rulers. In the seventh century, Arabs began a conquest of the area, bringing Islam to the region. Though initially opposing and revolting against Arab rule, the Berbers over several centuries began to integrate into Arab society. From the middle of the eighth century the duty and responsibility of the caliph, or figure of authority, was to provide care and protection to his subjects (raʿāyā), who were his dependents and paid taxes. From 800 to 909 AD, the Aghlabid Dynasty consolidated rule over the territory which they called Ifriqiya and established the Trans-Saharan trade routes in the area. The Aghlabids were overthrown by the Fatimid Caliphate and its Berber allies in 909. The Fatimid capital was relocated to Egypt in 973, leaving Ifriqiya in charge of its vassal state ruled by the Zirid dynasty.

The Zirid-Fatimid relationship broke in 1049, but with the help of Arab Bedouins the Fatimid defeated the Zirid forces and restored the vassalage. In 1087 Mahdia was occupied by Italian mariners from Genoa and Pisa, and in 1148, was taken by Norman troops. The Normans were ousted in 1159 by the Almohad Caliphate, which also overthrew the Zirid dynasty in the twelfth century. The Almohads established Tunis as their capital of Ifriqiya and in 1207, assigned the governorship of Ifriqiya to the Abu Muhammad Abd al-Wahid ibn Abi Hafs, founder of the Hafsid dynasty. After administrating the territory for the Almohads for over two decades, in 1229, the dynasty proclaimed its independence and would remain in power for the next three centuries.

Spanish and Ottoman conflicts (1492–1574) After Spain completed the centuries-long reconquista of taking back the Iberian Peninsula from Muslim rule, a plan was formulated to establish a series of presidios in ports along the North African coast. In 1495, Jerónimo Vianello (aka Gerónimo Vianelli), a Venetian mariner, was sent to evaluate the possibilities for capturing sites on the African coast. Muslim states in North Africa, facing the possibility of Christian invasion appealed to the Ottoman Empire to intervene. The emperor, busy trying to quell Cem's rebellion, authorized sea ghazis to come to their aid. Between 1505 and 1510, Spain captured and occupied Mers-el-Kebir, Oran, Tripoli, and Bougie, and made treaties for trading with other ports, such as Algiers. Increasingly, the Hafsids found themselves caught between the Ottoman and Spanish rivalry. In 1534, the Ottomans captured Tunis and were able to hold it for a year, before a combined force of Hafsids and Spanish recaptured the city. In return, the Hafsid dynasty became a vassal of Spain. The Ottoman forces retook Tunis in 1569, but it was freed by Spain in 1573, before finally being conquered by the Ottomans in 1574 and ending the Hafsid rule and Spanish claims to the area.

Ottoman rule (1574–1881) In 1574, with the defeat of the Hafsid dynasty, 4,000 Janissary, military forces, were left in Tunis to assist in governance of Ottoman Tunisia. Establishing suzerainty over the area, the Sublime Porte appointed a pasha (governor) assisted by a bey, internal administrator and tax collector, and who consulted in governing with a divan (council) made up of local dignitaries and army officers. After a revolt by the Janissary in 1591, the pasha was forced by military officers, known as deys, to establish military rule. Having disbanded the divan, the deys laid the foundation for dynastic rule and within a few decades, their power was eclipsed by the bey, with the creation of the Muradid dynasty (1613–1705) which was followed by the Husainid dynasty and remained in power until 1957.

Within the Ottoman Empire (1299–1922) for six centuries, there was an internal organization that defined government functions for subjects by balancing religious and communal ties, weighing aptitudes and occupations without a centralized national ideology. Ottoman subjecthood was strongly tied to religion and non-Muslims, if they were ahl al-Kitāb (People of the Book), meaning Jewish, Christian, or Zoroastrian, could benefit from being subjects by agreeing to pay a tax to the sultan. Under a pact known as zimma, in exchange for paying taxes, the sultan allowed these subjects freedom of religion and guaranteed their lives, property, and rights with an understanding that they were legally entitled to less status than Muslim subjects. The pact was agreed to by the leaders of the confessional community, who managed the adherents and their internal organization under the religious law of their community.

By the eighteenth century a political organization, known as the millet, managed the affairs of their respective religious communities and developed into the protégé system (, protected persons). Signing treaties with European powers, from the 1673 signing of a Capitulation with France, the Ottoman Empire granted France control of certain Ottoman Christians, Austria control of some Ottoman Roman Catholics, most favoured nation status to British and Dutch traders, as well as specific rights to the Republic of Venice and Russian Empire. Under the terms of these treaties, foreign powers could recruit Ottoman subjects to serve their needs as commercial agents, consuls, or interpreters, and extend to these protégés diplomatic immunity from prosecution and privileges of trade, including lowered customs tariffs. Over time, abuses of the system led to a virtual monopoly of foreign trade by protégés, clandestine sales of letters patent (), and demands from foreign powers for protection to extend from individuals to entire communities. The influence on Ottoman subjects by European powers changed the perception of these minority groups in the empire, meaning that they were increasingly seen not as Ottoman subjects, but as resident aliens.

To curb the disruptive effects of Europeans in the empire, from 1806, the Ottoman government began sending communiques to the foreign embassies demanding compliance with the terms of their agreements. Failing to achieve success diplomatically, in 1839, the Ottoman government issued the Edict of Gülhane, in an effort to end bribery and corruption, and to create fair tax schemes and institutions to protect the basic rights of Ottoman subjects. The Ottoman Reform Edict of 1856 () categorized subjects by whether they were Muslim or non-Muslim, granting different civil statuses to each, but establishing the principal of equality under the law. In 1857, after the Tunisian bey had executed a Jewish man for blasphemy, pressure from British and French diplomats led to enactment of the "Pact of Security" (ʿahd al-amān, or pacte fondamental) on 10 September. Though not a full constitution, or bill of rights, it contained eleven principles for due process and equal protection for foreigners in the areas of commerce, criminal prosecution, military service, property rights, religious freedom, and taxation. The Pact made clear that it was between the bey and his subjects and made no mention of Ottoman sovereignty.