The law of Libya has historically been influenced by Ottoman, French, Italian, and Egyptian sources. Under the Great Socialist People's Libyan Arab Jamahiriya, Libya has moved towards a legal system based on sharia, but with various deviations from it.
When Libya was ruled by the Ottoman Empire, the civil law was the Majallat al-ah Kam al-ad Liyat. In 1830, the Ottoman Empire adopted the Napoleonic Code as its commercial code. However, Islamic law continued to influence other areas, for example, the 1858 Ottoman Land Code, which comprised a mix of Turkish traditional practises and Islamic law. By 1870, the Senussi movement of Sufi- and Salafi-influenced jurist Muhammad ibn Ali as-Senussi had also effectively established an alternative legal system, more purely based on Islamic law, for the tribes of inland Libya. The coastal portion of Libya was also administered as an Italian colony from 1911 to 1943, bringing Italian law into Libya as well.
In the 1950s under King Idris, completely new codes based on French and Italian civil law were drafted, including the Commercial Code of 1953 and the Civil Code of 1954. The latter was written by Abd El-Razzak El-Sanhuri, the author of the 1948 Egyptian Civil Code, which itself was based on the French civil law, but also recognised sharia and Arab customs as a source of law. Arab customs were ranked by Article I of the Libyan code as third as a source of law in Libya, behind sharia; this compares to its ranking of second, ahead of sharia, in other countries adopting Sanhuri codes such as Egypt and Iraq. European laws were imported and applied in fields where sharia law was less developed, namely commercial law, procedural law, and penal law. Islamic influence remained in some areas of commercial law too, however; Libya was the first country adopting the Sanhuri code to prohibit riba (usury).