Libya's Colonel Muammar Gaddafi has been Africa's and the Arab world's longest-ruling, most erratic, most grimly fascinating leader - presiding for 42 years over this desert republic with vast oil reserves and just 6 million people.
For years, he was an international pariah blamed for the 1988 bombing of a Pan Am jumbo jet over Lockerbie, Scotland, that killed 270 people. After years of denial, Libya acknowledged responsibility, agreed to pay up to $10 million to relatives of each victim, and Gaddafi declared he would dismantle all weapons of mass destruction.
That eased him back into the international community.
In February, one week into the uprising, Gaddafi vowed to die as a "martyr" on Libyan soil
But in February, days after the uprising against him began; Gaddafi gave a televised speech amid violent social unrest against his autocratic rule. In the speech, he vowed to hunt down protesters "inch by inch, room by room, home by home, and alleyway by alleyway."
The speech caused a furor that fuelled the armed rebellion against him and it has been since mocked in songs and spoofs across the Arab world.
Gaddafi came to power in 1969 after leading a bloodless coup toppling King Idris at the age of 27. He maintained tight control of his oil-rich country for decades by clamping down on dissidents.
He was born in 1942 in the coastal area of Sirte to parents who were nomads. He went to Benghazi University to study geography but dropped out to join the army.
After seizing power, he laid out a pan-Arab, anti-imperialist philosophy, blended with aspects of Islam. While he permitted private control over small companies, the government controlled the larger ones.
He was an admirer of the Egyptian leader Gamal Abdel Nasser and his Arab socialist and nationalist ideology.
He tried without success to merge Libya, Egypt and Syria into a federation. A similar attempt to join Libya and Tunisia ended in acrimony.
In 1977 he changed the country's name to the Great Socialist Popular Libyan Arab Jamahiriyah (State of the Masses) and allowed people to air their views at people's congresses.
However, critics dismissed his leadership as a military dictatorship, accusing him of repressing civil society and ruthlessly crushing dissident.
The regime has imprisoned hundreds of people for violating the law and sentenced some to death, according to Human Rights Watch.
At the UN General Assembly in 2009, Gaddafi accused the body of being a terrorism group like al-Qaeda [EPA]
"Gaddafi, gradually as he took power, he used force and he used brutality," Mohammed al-Abdalla, the deputy secretary-general of the National front for Salvation of Libya, told Al Jazeera.
"In the 1970s against students, when he publicly hung students who were marching, demonstrating, demanding rights in Benghazi and in Tripoli and many other squares, and his opposition members abroad in the 1980s, including here in London and other places in Europe and in in Arab Middle East.
"He executed, in probably the most brutal massacre that we saw, 1,200 prisoners in the Abu Salim prison who were unarmed, They were already in jail, he executed them in less than three hours."
Gaddafi played a prominent role in organising Arab opposition to the 1978 Camp David peace agreement between Egypt and Israel.
Later shunned by a number of Arab states on the basis of his extreme views on how to settle the Israeli-Palestinian conflict among others, Gaddafi's foreign policy shifted from an Arab focus to an African focus.
His vision of a United States of Africa resulted in the foundation of the African Union.
Among his many eccentricities, Gaddafi is known to sleep in a Bedouin tent guarded by dozens of female bodyguards on trips abroad.
In the West, Gaddafi is strongly associated with "terrorism", accused of supporting armed groups including FARC in Colombia and the IRA in Northern Ireland.
Libya’s alleged involvement in the 1986 bombing of a Berlin nightclub in which two American soldiers were killed prompted US air attacks on Tripoli and Benghazi, killing 35 Libyans, including Gaddafi’s adopted daughter. Ronald Reagan, the then US president, called him a "mad dog".
The 1988 bombing of the Pan Am flight over Lockerbie in Scotland is possibly the most well known and controversial international incident in which Gaddafi has been involved.
For many years, Gaddafi denied involvement, resulting in UN sanctions and Libya’s status as a pariah state. Abdel Basset al-Megrahi, a Libyan intelligence agent, was convicted for planting the bomb. Gaddafi's regime formally accepted responsibility for the attack in 2003 and paid compensation to the families of those who died.
Also in 2003, Gaddafi broke Libya's isolation from the West by relinquishing his entire inventory of weapons of mass destruction.
In September 2004, George Bush, the US president at the time, formally ended a US trade embargo as a result of Gaddafi's scrapping of the arms programme and taking responsibility for Lockerbie.
The normalisation of relations with Western powers has allowed the Libyan economy to grow and the oil industry in particular has benefited.
However, Gaddafi and Lockerbie came back into the spotlight in 2009, when al-Megrahi was released and returned to Libya. The hero’s welcome al-Megrahi received from Gaddafi on his return was condemned by the US and the UK, among others.
In September 2009, Gaddafi visited the US for the first time for his first appearance at the UN General Assembly.
His speech was supposed to be 15 minutes, but exceeded an hour and a half. He tore up a copy of the UN charter, accused the Security Council of being a terrorist body similar to al-Qaeda, and demanded $ 7.7 trillion in compensation to be paid to Africa by its past colonial rulers.
During a visit to Italy in August 2010, Gaddafi's invitation to hundreds of young women to convert to Islam overshadowed the two-day trip, which was intended to cement the growing ties between Tripoli and Rome.
Inspired by revolutions in Tunisia and Egypt, Libyans began to hold peaceful protests against his regime in February of this year.
Demonstrations were met with military force and the uprising escalated into a civil war, with NATO-led forces later siding with the rebels.
On June 27, the brutal actions of the government were referred to the International Criminal Court and an arrest warrant for Gaddafi was issued for crimes against humanity.
Gaddafi repeatedly blamed the unrest on al-Qaeda and a "colonialist plot". He called those opposed to him "rats", and alleged that they had been influenced by "hallucinogenic drugs".
The war raged on for months, with slow gains for the opposition. Eventually, the rebels entered Tripoli on August 21.
Al Jazeera and agencies