After 42 years at the helm of his sparsely populated, oil-rich nation, Muammar Gaddafi - the Arab world's longest-ruling leader - lost his grip on power after a six-month uprising.
Since he lead a successful military coup in 1969, Gaddafi styled himself as Libya's "brother leader" and the "guide of the revolution," as an almost paternal figure looking after Libya's six million inhabitants.
His relationship with the rest of the world was erratic. For years, Gaddafi was known in the West as a pariah, blamed for the 1988 bombing of a Pan Am jumbo jet over Lockerbie, Scotland, which killed 270 people. After years of denial, Libya acknowledged responsibility and agreed to pay up to $10m to relatives of victims; Gaddafi also declared he would dismantle all weapons of mass destruction.
Those moves eased him back into the international community.
In February, only weeks after street protests brought down the leaders of Tunisia and Egypt, a rebellion against Gaddafi's rule started in the country's east.
Days after it began, Gaddafi gave a televised speech in which he vowed to hunt down protesters "inch by inch, room by room, home by home, alleyway by alleyway." The speech caused anger that fuelled the armed rebellion against him.
He was born in 1942 in the coastal area of Sirte to nomadic parents. He went to Benghazi University to study geography but dropped out to join the army.
Gaddafi came to power in 1969 at the age of 27 after leading a bloodless coup against King Idris.
After seizing power, he laid out a political philosophy based on pan-African, pan-Arab and anti-imperialist ideals, blended with aspects of Islam. While he permitted private control over small companies, the government controlled the larger ones.
The Libyan leader was an admirer of the Egyptian leader Gamal Abdel Nasser and his Arab socialist and nationalist ideology. As a strong member of the Non-Aligned Movement during the Cold War era, he tried to mold the Libyan political system in a way which he said was an alternative to both capitalism and communism.
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, partly on the basis of his views on the Israeli-Palestinian conflict, Gaddafi's foreign policy focus shifted from the Arab world to Africa.
Gaddafi argued for the creation of a "United States of Africa" - an idea first thought of by US pan-Africanist Marcus Garvey - in which the continent would include "a single African military force, a single currency and a single passport for Africans to move freely around the continent". He also supported membership among countries in other parts of the world whose citizens are mostly part of the African diaspora, including Haiti and Jamaica.
The project did not pan out, although some of its ideas were embedded in the African Union, created in 2002. Gaddafi was elected chairman of the African Union from 2009 to 2010.
A 2008 meeting of African monarchs proclaimed Gaddafi the continent's "king of kings".
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.
Some 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.
"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 has maintained a position of anti-imperialism throughout his rule, supporting independence movements against colonial rule around the world. He has allegedly given material support to groups labelled "terrorists" by numerous wealthy countries, including Colombia's FARC and Northern Ireland's IRA.
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, then the US president, called him a "mad dog".
The 1988 Pan Am bombing over Lockerbie is possibly the most well-known and controversial 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 of planting the bomb. In 2003, Gaddafi's regime formally accepted responsibility for the attack and paid compensation to the families of those who died.
Gaddafi also broke Libya's isolation from the West in the same year 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 from a Scottish prison on the grounds that he was terminally ill and was nearing death. He returned to Libya to a hero's welcome from Gaddafi and many Libyans, sparking condemnation by the 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 last 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.7tn 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 uprisings in Tunisia and Egypt, Libyans began to hold protests against his regime in the eastern city of Benghazi in February of this year.
Demonstrations were met with military force and the protests escalated into an all out armed conflict, with NATO-led forces intervening to ostensibly protect civilians but giving material aid, and later openly siding with the opposition forces.
On June 27, the brutal actions of the government were referred to the International Criminal Court and arrest warrants were issued for Gaddafi, one of his sons and his spy chief on charges of 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". In his last address before rebels entered Tripoli, he accused "Western intelligence" of "working with al-Qaeda to destroy Libya."
His current whereabouts are unknown, though it seems increasingly unlikely that he is still in the Libyan capital.
Source: Al Jazeera and agencies