Until then, King Idriss Sanussi had managed to survive the post-1952 revolutionary ferment in the Arab world, which spared neither sultan nor imam, leading to popular revolutions in Egypt, Iraq, Yemen and Algeria, as well as leftwing regimes in Syria and Lebanon. The wily crock had managed to survive by a deft combination of support from the United States (Libya had the world's largest American airbase, the Wheelus) and the old colonial power, Italy.

Gaddafi's military coup in Libya resembled many other coups throughout the Arab world as well as in Latin America, where nationalist, often leftwing, junior military officers helped in getting rid of unpopular US clients. Young Gaddafi was immediately hailed by Gamal Abdel Nasser, the lodestar of the Arab nationalist movement and president of Egypt, who bore the brunt of American, Israeli, British and French vengeance throughout the 1950s (the 1952 Anglo-French-Israeli raid on Suez) and 1960s (the 1967 war) because of his popular anti-imperialist programme and support for the Palestinian right of self-determination.

In Libya, Gaddafi set about undoing precisely what had made the country a byword for a client state under the Sanussis. The Wheelus was swiftly dismantled, Italian property and oil multinationals were nationalised and education, health and housing were decreed free for common Libyans.

Not since the great anticolonial strategist Omar Mukhtar – known to his Italian adversaries as the Lion of the Desert – had the country seen such a charismatic, unifying figure. Gaddafi, in thrall to his hero Nasser, declared Libya a socialist state and set about achieving the elusive ideal of Arab unity that was to be the undoing of so many of his generation in the catastrophic Arab-Israeli war of 1973, in which the US-backed Israeli army inflicted a decisive defeat on combined Arab armies.

He made himself popular with the Arab masses by espousing the cause of Palestine as well as championing national liberation movements around the world, from the Irish Republican Army to the Moros in the Philippines; the Black September revolutionaries who in 1970 nearly toppled the American-Israeli protectorate of Jordan (then ruled by the unpopular King Hussein) until reinforcements arrived to restore the status quo – led by a bloodthirsty Pakistani officer, Brigadier Zia (who just seven years later would go on to brutalise Pakistan for 11 years as its worst military dictator); revolutionary Iran and the Polisario Front fighting for an independent homeland in the western Sahara.

In a region marked by the ascendance of sultans, emirs and colonels who had betrayed the hopes of their people for emancipation by signing up to a peace dictated by the US and Israel, Muammar Gaddafi provided a breath of fresh air by not only taking a stand for the beleaguered Palestinians but for international solidarity with national liberation movements, which won him the comradeship of fellow survivors Fidel Castro of Cuba and Nelson Mandela of South Africa.

Obviously, this would not go unpunished. Ronald Reagan bombed Tripoli in 1986, killing Gaddafi's infant daughter, Hana. Whatever the international dynamics of Gaddafi's implication in the Lockerbie affair, few of his fellow countrymen actually believe that their leader is involved; they see it as just another attempt to target him. Following 9/11, Gaddafi decided to trade battle fatigues for more promising get-rich-quick rewards, and accepted responsibility for Lockerbie in order to shift his loyalties to the west and to be on the "right side of history". As a result, he has been rewarded with swift rehabilitation from rogue leader to a statesman, meriting visits by western dignitaries as well as a certain Professor Anthony Giddens.

As a result of this about-face, Libya now stands to earn $36bn a year from its oil. Most of these earnings have not reached the people but are now being used to Miami-scape Tripoli, as the next big oil capital of the Arab world.

Libya under Gaddafi is well on its way to becoming a family-owned dictatorship, with his playboy son Seif al-Islam as the heir apparent – and itching to privatise everything his father had nationalised on coming to power in 1969.

It need not have been like this had Gaddafi listened more keenly to his hero, Nasser, who once declared: "I rather like Gaddafi. He reminds me of myself when I was that age."

He could still have been a hero to Libyans as well as thousands of Arabs. But not Muammar Gaddafi. As he relishes 40 years as the Great Leader, he must know that he is now Washington's favorite dictator in the Arab world after Hosni Mubarak in Egypt and Zine el Abidine ben Ali in Tunisia. He is certainly the last of the generation of Arab nationalists who believed in Arab nationalism as a genuinely progressive ideology and a realistic project, giving hope to millions and freedom from the oppression of pashas, emirs and colonels like himself.

The Great Leader of Libya, the author of the revolutionary text on statecraft, The Green Book, and of 15 other fictional creations, must also surely know the words of another great leader, Saint Just, who had said at the time of the French Revolution, as a warning: "Those who make half the revolution dig their own graves." Amen to that.