Libya has been inhabited by Berbers since the late Bronze Age. The Phoenicians established trading posts in western Libya, and ancient Greek colonists established city-states in eastern Libya. Libya was variously ruled by Carthaginians, Persians, Egyptians, and Greeks before becoming a part of the Roman Empire. Libya was an early centre of Christianity. After the fall of the Western Roman Empire, the area of Libya was mostly occupied by the Vandals until the 7th century, when invasions brought Islam to the region. In the 16th century, the Spanish Empire and the Knights of St John occupied Tripoli, until Ottoman rule began in 1551. Libya was involved in the Barbary Wars of the 18th and 19th centuries. Ottoman rule continued until the Italian occupation of Libya resulted in the temporary Italian Libya colony from 1911 to 1943. During the Second World War Libya was an important area of warfare in the North African Campaign. The Italian population then went into decline.
Libya became independent as a kingdom in 1951. A military coup in 1969 overthrew King Idris I. The coup leader Muammar Gaddafi ruled the country from the Libyan Cultural Revolution in 1973 until he was overthrown and killed in the War of 2011.
It is a member of the United Nations (since 1955), the Non-Aligned Movement, Arab League, OIC, and OPEC. The country's official religion is Islam, with 96.6% of the Libyan population being Sunni Muslims.
In the second Libyan Civil War ongoing since 2014, two authorities initially claimed to govern Libya: the Council of Deputies in Tobruk, and the 2014 General National Congress (GNC) in Tripoli, which considered itself the continuation of the General National Congress, elected in 2012. After UN-led peace talks between the Tobruk and Tripoli governments, a unified interim UN-backed Government of National Accord was established in 2015, and the GNC disbanded to support it. Parts of Libya remain outside either government's control, with various Islamist, rebel, and tribal militias administering some areas. As of July 2017 talks are still ongoing between the GNA and the Tobruk-based authorities to end the strife and unify the divided establishments of the state including the Libyan National Army and the Central Bank of Libya.