After four decades in power, Col Muammar Gaddafi was ousted when rebels took the capital Tripoli in August 2011. Gaddafi and his family went on the run and on 20 October 2011 the former leader was captured and killed on the outskirts of Sirte. Eight months of civil war had come to an end.
Three weeks later, Gaddafi's son Saif al-Islam was captured while trying to flee the country. He now faces trial in Libya for financial corruption, murder and rape.
The National Transitional Council (NTC), which led the revolt, was then recognised by the UN as Libya's legitimate ruling body.
Libya's uprising began in mid-February 2011 with a demonstration calling for human rights in the eastern city of Benghazi by the families of some of the 1,200 inmates massacred at the Abu Salim prison in 1996. After security forces arrested an organiser and then opened fire on the crowd as they demanded his release, the protests in Benghazi grew more widespread. They then began in other eastern towns before eventually reaching Tripoli.
The revolt soon evolved into an armed conflict pitting forces loyal to Gaddafi against rebel forces based in Benghazi.
In March 2011, the UN Security Council passed a resolution which authorised "all necessary measures" - except troops on the ground - to protect civilians.
Operations by the Nato-led military alliance were largely confined to air attacks, initially aimed at imposing a no-fly zone and later widened to include government targets. Following six months of fighting, rebel forces took Tripoli, after gaining pockets of territory in the west.
Several thousand people were killed and many more injured in the conflict and human rights groups reported extensive abuses by both sides.
Three days after Gaddafi was killed, the NTC declared Libya officially "liberated".
However, since then Libya has been plagued by instability; rival militias have clashed repeatedly, and regional and ethnic tensions have persisted. The country's first free national elections for a new parliament nevertheless passed off relatively peacefully in July.
The assembly was originally tasked with appointing a panel to write a new constitution, but after some in the east raised concerns about under-representation, the NTC announced that a 60-member committee to write a new constitution would be elected at a later date.