ALGIERS (Reuters) - Behind his image as a crazed tyrant, Libya's Muammar Gaddafi is fiercely intelligent, loves his family and just might do what everyone is least expecting and let go of power.
The battle over Libya, now in its fifth month, is a contest of Western military technology, money, oil, diplomacy, rag-tag rebels and a stubborn system of government that has refused to be swept away by the wave of "Arab Spring" uprisings.
Ultimately though, it is a battle whose outcome could boil down to the decisions made by one man: Muammar Gaddafi.
The view of Gaddafi commonly held outside Libya -- with his safari suits, retinue of female bodyguards and his ruthless repression of opponents -- is of a volatile and violent dictator who will fight to the last drop of blood.
Former U.S. President Ronald Reagan coined the phrase "Mad Dog" of the Middle East to describe Gaddafi. Some of Gaddafi's personal behaviour lends support to that view.
This reporter saw an angry Gaddafi slap one of his protocol officials hard on the back with both hands during an international summit. The sound of the blow reverberated around the marble hallways of the summit venue.
Nor has he shied from spilling blood. More than 1,000 inmates were killed in a Tripoli prison in 1996. The International Criminal Court has issued a warrant accusing him of crimes against humanity in the killing of civilian protesters. Opponents have disappeared.
But the portrait drawn from leaked diplomatic cables and the accounts of people who have watched him for decades is of a man who is more complex than the stereotypes suggest and who has a capacity to confound predictions of what he will do next.
"Personally I think that he will keep surprising us to the end," said Oliver Miles, a former British ambassador to Libya.
"One way he might surprise us, I suppose, because suicide is not an Arab thing, he might do a Hitler, but I think on the whole it is more likely that he would do something else, that he'd retire in ... a cloud of glory to some African destiny as retired king of kings."
David Mack was a young American diplomat when he first met Gaddafi, soon after the Libyan had led a 1969 military coup to oust Libya's king and install revolutionary rule.
Mack translated for the then U.S. ambassador at a meeting with Gaddafi. His recollection is of a man who was "extremely intelligent, very high IQ."
"He had total recall from one meeting to another and he was capable of great tactical flexibility," said Mack, who went on to become U.S. Deputy Assistant Secretary of State for Near East Affairs.
Years later, Gaddafi was still showing the same intellectual power. Senior Libyan officials are often ordered to translate works on political theory for him to read.
His reading list at one point in 2008 included Barack Obama's "Audacity of Hope" and George Soros' "The Age of Fallibility: Consequences of the War on Terror," according to U.S. diplomats who saw the books stacked on an advisor's desk.
When Libya emerged from isolation half-way through the last decade, Gaddafi was keen to show off his erudition to his new Western visitors.
"I remember being very struck by the fact that when American Congressmen started coming to see him ... when for the very first time there was contact, people were talking about him being on his last legs, possibly mentally sick," said Miles.
"But after a three-hour session it would be the American congressmen who would come out exhausted, not Gaddafi."
He approaches meetings with his own officials with the same rigour, said Noman Benotman, a former Libyan dissident who knows members of the Gaddafi inner circle.
"It's very common for government ministers to get a call at midnight," said Benotman.
He said some senior officials prepared for meetings with Gaddafi with lengthy academic-style research to avoid being caught out by his probing questions.
Gaddafi's ability to analyse events objectively has eroded over the years, said Mack, now a scholar at the Washington-based Middle East Institute.
Mack was among a group who met Gaddafi in New York in September 2009, hours after he had delivered a rambling 90-minute address to the United Nations General Assembly.
"Being in a system of absolute power, where no one told him no, his emotional and intellectual development became frozen," he said. "I do not think he has the capacity to adjust easily to changed circumstances."
Nevertheless, Gaddafi still held huge power over Libyans. On the same day Mack met Gaddafi in New York, waiters in a hotel restaurant in central Tripoli stopped work and sat down at the tables to watch their leader's UN speech on television.
As he approached his 40th year in power, people close to Gaddafi said he was beginning to believe the personality cult around him.
Gaddafi "perceives himself as a 'superman of history' and is not able to admit fault or weakness," a 2008 U.S. embassy cable, published by WikiLeaks, quoted a well-connected Libyan as saying.
There were outwards signs of this. He designed a car, and had several prototypes built by an Italian manufacturer. In the latest version, it was shaped like a lozenge, with one wheel at the front, one at the back, and two in the middle.
Gaddafi also tinkered with the Muslim calendar. He decreed in 2009 that the Eid al-Adha religious holiday would be a day earlier in Libya than in most other parts of the Arab world.
His own lifestyle is frugal. He drinks camel's milk every day and likes traditional Libyan pasta with lots of chili, according to Benotman, the former dissident.
He often works through the night -- one diplomat said he liked to surf the Internet into the small hours of the morning checking what was being written about Libya.
He also rises late. Foreign heads of state at one summit in Libya had to wait hours for Gaddafi to arrive.
Rumours have circulated about Gaddafi's health. Diplomatic cables mention unconfirmed reports of mini-strokes and cancer, and his difficulty in climbing long flights of stairs.
At times his speech in public has been slurred, and his face has appeared swollen. Since this crisis broke out though, he has been his most animated in years.
One constant that has changed little throughout Gaddafi's long rule is the importance he attaches to his family, something which could, in the end, persuade him that relinquishing power and going into exile is the only course of action.
Observers say he is close to his second wife, Safia. He is fiercely protective of his children. He halted oil exports to Switzerland when one of his sons, Hannibal, was briefly arrested at a luxury hotel in Geneva.
Not all his children share their father's stubbornness. Both his daughter, Aisha, and another son, Saif al-Islam, have spoken of possible political deals.
"He is a political tyrant and he is also a person of rigid views but he is also a father and grand-father," said Mack. "An Arab grand-father has to care about the fate of his children and grand-children."
"I think he can be moved by them if they say to him: 'Papa , we have to at least save the rest of us from being killed or brought up before the international court' and there is an offer and there is a ... plane waiting.'."
Additional reporting by William Maclean in London; Editing by Giles Elgood