With the decline of the local Berber dynasties in the 15th and 16th centuries, the valuable coastal strip of north Africa (known because of the Berbers as the Barbary coast) attracts the attention of the two most powerful Mediterranean states of the time - Spain in the west, Turkey in the east.
The Spanish-Turkish rivalry lasts for much of the 16th century, but it is gradually won - in a somewhat unorthodox manner - by the Turks. Their successful device is to allow Turkish pirates, or corsairs, to establish themselves along the coast. The territories seized by the corsairs are then given a formal status as protectorates of the Ottoman empire.
The first such pirate establishes himself on the coast of Algeria in 1512. Two others are firmly based in Libya by 1551. Tunisia is briefly taken in 1534 by the most famous corsair of them all, Khair ed-Din (known to the Europeans as Barbarossa). Recovered for Spain in 1535, Tunisia is finally brought under Ottoman control in 1574.
Piracy remains the chief purpose and main source of income of all these Turkish settlements along the Barbary coast. And the depredations of piracy, after three centuries, at last prompt French intervention in Algeria. This, at any rate, is stated by the French at the time to be the cause of their intervention. The reality is somewhat less glorious.
Algiers is occupied by the French in 1830, but it is not until 1847 that the French conquest of Algeria is complete - after prolonged resistance from the Berber hinterland, which has never been effectively controlled by the Turks on the coast.
It is in the European interest to police this entire troublesome Barbary region. Tunisia becomes a French protectorate in 1881, and Morocco (which has maintained a shaky independence, under its own local sultans, since the end of the Marinid dynasty) follows in 1912. Italy takes Libya from the Turks in 1912. The regions of the Barbary coast thus enter their last colonial phase before independence.
Italo-Turkish War: AD 1911-1912
Turkish control over over the region of modern Libya has been little more than nominal during much of the Ottoman period. In the western region, Tripolitania, the descendants of an Ottoman governor, Ahmad Karamanli, win hereditary rights as pashas in 1711 and retain them until 1832. In the eastern district of Cyrenaica real power resides with the Senussi, followers of a 19th-century religious reformer (al-Senussi al-Kabir), whose creed of a strict and simple Sunni life proves popular with the Bedouin tribesmen.
But the eventual removal of the Turks from the region is not the result of local antagonism. It derives from the wish of Italy, a latecomer in the imperial scramble, to increase her stake in Africa while there is time.
By the first decade of the 20th century Algeria and Tunisia are French. Egypt is British. Libya, situated between these French and British regions, is a part of north Africa in which Italy has been developing extensive commercial interests. In 1900 the French and Italian governments come to a cool-headed secret agreement. France has designs on Morocco, Italy on Libya. Each will allow the other a free hand.
In 1911 Italy finds a trumped-up reason to send a 24-hour-ultimatum to Istanbul, demanding the presence of Italian troops in Tripolitania and Cyrenaica to protect the local Italian population. This is followed a day later by a declaration of war and almost immediate invasion of north Africa.
The Italians make relatively little headway, partly because of a spirited resistance by the Sennusi tribesmen on behalf of their imperial masters, who at least are fellow Muslims. But by the autumn of 1912 Turkey, beset by troubles elsewhere, is ready to concede. Under the terms of a treaty signed in October at Ouchy (the lakeside district of Lausanne), Tripolitania and Cyrenaica are ceded to Italy.
The new imperial power soon also occupies Fezzan, a region to the southwest under Sennusi control. With the annexation of Fezzan, modern Libya takes shape - though as yet only as a broad area suffering and greatly resenting Italian occupation.
World Wars and Fascism: AD 1914-1945
In its short span of existence the Italian colony of Libya sees two world wars and the rise of fascism. These events have profound and differing effects in the region.
The demands of World War I cause Italian troops to be withdrawn until only the coastal towns of Libya are safely held. Elsewhere control returns to the network of local Senussizawiya (fortified outposts around a mosque). After the war the Senussi leader, Mohammed Idris, attempts to achieve a compromise with the Italians. In 1920 he acknowledges their sovereignty over coastal Cyrenaica. In return he is granted the title of emir. But this uneasy relationship crumbles with the onset of fascism.
Idris flees in 1923 to Egypt, while fascist governors in Libya take strong measures - including the use of concentration camps - to subdue resistance in Tripolitania and Cyrenaica. (The two provinces are united in 1934 to form the colony of Libya.)
World War II at last brings the Senussi into a winning team. As enemies of Italy, they are natural allies of Britain and the USA. They play their part in the all-important campaign of 1942-3 which drives the Italian and German armies out of north Africa.
During the later stages of the war and in the immediate postwar years Tripolitania and Cyrenaica are adminstered by the British, while Fezzan is under the control of the French. But it is agreed that the future of Libya shall be referred to the United Nations.
The result is a resolution for Libyan independence. In December 1950 a national assembly representing all three provinces elects Mohammed Idris to be Libya's king. As Idris I, he formally declares the independence of the new state on 24 December 1951.
Royal Libya: AD 1951-1969
Idris rules as an old-fashioned monarch, with scant regard for any democratic ideals. For the first eight years his realm is similarly backward, an impoverished region in which a subsistence economy is boosted only by revenues from British and US airbases and by international aid.
This situation is transformed in 1959 by the discovery of major oil reserves. Idris, with the luxury now of a massive national revenue, begins to assert Libya's new independence. Negotiations are begun to secure the withdrawal of foreign troops from Libyan soil. But the king's leisurely pace is suddenly trumped. In 1969, when absent on a visit to Turkey, he is deposed in a bloodless coup led by a 27-year old captain, Moamar al-Gaddafi.
The Gaddafi regime: from AD 1969
Gaddafi immediately becomes commander-in-chief of the armed forces and chairman of the Revolutionary Command Council which now governs Libya. From 1979 he is known simply as Leader of the Revolution, ruling with a firm grip which means that Libya's policies are entirely his own.
Gaddafi soon acquires a reputation as one of the world's more eccentric and unpredicable dictators. The various roots of his political philosophy - Islam, Arab nationalism, socialism - are combined in his personal manifesto The Green Book (published in two volumes, in 1976 and 1980).
An extra element is added in a new name of the country, introduced in 1977. It is now to be known as the People's Socialist Libyan Arab Jamahiriya. The phrase Jamahiriya ('government through the masses') implies that power is transferred to some 1500 local committees. But the reality remains very much a personal rule by one man.
Gaddafi's unpopularity on the international stage derives from his use of Libya's oil wealth to meddle in the affairs of other nations. Locally this means often tense relationships with Egypt and Chad. Further afield it brings international condemnation, as assassination squads eliminate Libyan opponents living abroad and Libyan funds support terrorist activities in far-flung parts of the world.
In 1972 Gaddafi announces that he is supporting the IRA in northern Ireland. Libyan cash is also believed to lie behind Black Panther and Nation of Islam activities in the USA, as well as funding terrorist acts by extremist Palestinian groups.
To demonstrate US commitment against international terrorism, President Reagan launches in April 1986 an air strike (in bombers flying from Britain) against what are said to be terrorist targets in Tripoli and Benghazi. Various members of Gaddafi's family are killed or wounded, and he himself narrowly escapes.
A new escalation in Libya's status as an international pariah follows the Lockerbie air disaster of 1988. A Pan Am airliner explodes over Lockerbie in Scotland, killing all 259 people on board and another eleven on the ground. Evidence later suggests that two Libyans may have been responsible for planting a bomb on board in Paris. But Gaddafi resolutely refuses to hand over the two suspects for trial.
This refusal leads to UN-approved sanctions from 1993. An embargo is placed on trade and air contact with Libya, followed by a ban on the sale of equipment needed for Gaddafi's oil industry.
Libya in the 1990s is a place increasingly isolated by the vagaries of one man (by now one of the world's longest established rulers). Almost immediately after taking power, Gaddafi expels in 1970 nearly all the Italians and Jews living in Libya. In 1995 he even throws Palestinians out of his Muslim state, along with citizens of neighbouring north African nations. He doubts their loyalty to Libya.
Thus Libyans, at the end of the century, are in a very real sense on their own in a hostile world. However isolation begins to end early in the new milliennium after Gaddafi allows the Lockerbie suspects to stand trial in the Netherlands. The UN sanctions are suspended, and Libya starts trying to attract tourists to its famous archaeological sites.