Both Tunisia and Libya were Islamized and Arabized upon the Muslim conquest of the Maghreb and were part of various emirates and Caliphates that ruled the region, such as the Aghlabids, Fatimids, Zirids and the Hafsids.
In the 16th century, they were absorbed into the Ottoman Empire as two distinct provinces until the Scramble for Africa began when France and Italy acquired control over them.
Tunisia, where the Arab Spring began, later spread into Libya and overthrew the regimes of both countries; however, the 2011 Libyan unrest had gone out of control after the death of Muammar Gaddafi caused the later second Libyan unrest which the growing Islamists tried to take control, Tunisia has been caught at the amidst of the conflict in Libya between the Tobruk-based Representatives and the Tripoli-based National Congress.
Tunisia constructed a defensive line alongside its borders with Libya, a physical barrier composed of a system of obstacles, including sandbags protecting water-filled trenches dug about 2 meters deep, elevated observation towers, and fences.
In August 2023, Tunisia and Libya reached a cooperation agreement to share the reception of sub-Saharan African migrants stranded at the border between the two countries.