The battle for Libya has at times seemed like a confusing stalemate. Rebel fighters push forward, excitedly claiming to have seized strategically important towns, only to retreat hours later under fire from forces loyal to Muammar Gaddafi.
But with opposition forces moving closer to Tripoli Al Jazeera looks back at some of the key developments which have shaped the conflict's course.
February 17: The Day of Revolt. The first major protests and violent clashes in Libya actually began two days before this, on February 15, mostly in Benghazi. Hundreds gathered outside the police station, and a number of protesters were killed.
Al Jazeera's report on the protests across Libya
But February 17 was the official "day of revolt," an effort to bring thousands of protesters into the streets. Major demonstrations were reported in Benghazi, Ajdabiya, Darnah and Zintan, among others; Gaddafi forces responded by firing live ammunition at the crowds. More than a dozen demonstrators were killed.
Gaddafi reportedly released dozens of prisoners from jail and paid them to fight against the protesters.
The "day of revolt" coincided with the fifth anniversary of a major anti-Gaddafi protest in Benghazi.
Protests continued to escalate after February 17, and there were widespread reports that Gaddafi had hired mercenaries to supplement his security forces and suppress the demonstrations.
February 20: Rebels take Benghazi. After several days of fighting, and hundreds of people killed, anti-Gaddafi fighters seized control of Libya's second city.
Cities further east, including Baida and Tobruk, were already under rebel control at this point. Doctors at Benghazi's ill-equipped hospitals said more than 300 people were killed in several days of fighting, which included numerous attacks on funeral processions.
The key event in the battle for Benghazi was the fall of the Katiba, the city's well-stocked military garrison staffed by (among other units) the feared Khamis Brigade. Fighters armed with rifles and homemade bombs laid siege to the garrison for several days, and a reported suicide car bomber eventually blew a hole in the building's gate, allowing the fighters inside.
Gaddafi would continue to launch sporadic attacks on Benghazi in the weeks to come, but would never regain control of the city.
March 10: Gaddafi bombs Brega; retakes Zawiyah, Bin Jawad. Further west, though, the early weeks of the war did not go well for the rebels.
The rebels looked in danger of losing Benghazi for several days in March
After an initial advance, Gaddafi began pushing the rebels back. His military shelled Ras Lanuf, a key oil port in eastern Libya, and seized the nearby town of Brega; there was also fierce fighting in Ajdabiya, another stop on the road to Benghazi.
Residents in the "rebel capital" grew increasingly fearful of bombing raids from Gaddafi's air force.
A small revolt in Zawiyah, 50km to the east of Tripoli, was quickly crushed by Gaddafi's forces; that early defeat made many Libyans in the east reluctant to oppose the government.
Gaddafi delivered several memorable speeches on Libyan state TV in late February and early March. He often blamed the protests on foreign intervention, and threatened to hunt down the protesters - "alley to alley, house to house."
The rebel losses in the east were a major reason for the push for a no-fly zone over Libya.
March 19: NATO starts bombing Libya. After a debate, the United Nations Security Council voted to impose a no-fly zone over Libya. Ten of the council's 15 members voted "yes," while five - Russia, China, India, Germany and Brazil - abstained.
The resolution called for international military action to protect civilians. It would be enforced primarily by NATO, with logistical support from several Arab countries, including Qatar and the United Arab Emirates.
French jets began bombing Libya just hours after the resolution was passed, with bombers from the United States, the United Kingdom and other countries joining shortly afterward.
Rebel commanders would frequently complain about the pace of NATO air strikes (they wanted more), and several of them missed their intended targets and killed rebel fighters instead. But the bombing campaign was undeniably a major reason why Gaddafi's military advance halted in mid-March.
May 15: Gaddafi forces withdraw from Misrata. The seaside city of Misrata was besieged for months by Gaddafi forces; they surrounded it and frequently lobbed mortars downtown.
Hundreds of civilians and rebel fighters were killed, and thousands more wounded, during weeks of fighting in the city centre and near the port. Civilians reported appalling living conditions: scarce food and water, little to no electricity, and a severe shortage of medical supplies.
NATO planes began bombing the city in late April, targeting Gaddafi's tanks and artillery. Rebels began their own counter=offensive on April 25, pushing slowly from the east, seizing the port area and working their way through the city.
A fierce battle on May 11 left the rebels with control of the airport, and four days later they declared the battle for Misrata over.
July 28: Major push in the Western Mountains.
Rebel gains in the east slowed down after the Misrata campaign, but they began winning territory in western Libya, allowing them to surround Gaddafi in Tripoli.
The western campaign allowed rebel fighters to control Libya's main supply lines
The rebels began their push in early June, and for several weeks they reported steady gains, capturing scattered villages and seizing much-needed supplies from the Gaddafi troops stationed in the region.
Their advance was halted in early July at the town of Qawalish. It took several advances to seize the town; rebels had to retreat at one point because they ran out of ammunition.
By late July, the rebels were pushing down from the Nafusa Mountains to towns in the foothills, allowing them to control strategically-important roads linking Tripoli to Tunisia - Gaddafi's main source of supplies.
Rebels would seize several other important towns, including Tiji and Bir al-Ghanam, after the start of Ramadan in August.
August 15: Rebels take Gharyan.
The war's final phase seemed to begin last week, when rebels reported taking control of Gharyan, a town about 80km south of Tripoli.
That victory allowed them to completely encircle the Gaddafi-controlled capital: All of the major highways leading out of Tripoli now pass through rebel-controlled areas.
Control of Gharyan, and the town of Zawiyah in the west, is not yet absolute; there are still reports of scattered shelling by Gaddafi's artillery. But the Libyan leader has been unable to retake these towns, and with reports of fighting on the streets of Tripoli, his grip on power is weaker than ever.
August 16: Tripoli isolated. Libya’s rebels say they have completed moves to cut off roads to the capital.
August 18: Opposition forces seize vital oil refinery. Reports confirm the oil plant near Az Zawiyah was taken and rebels were in complete control of Gharyan. Battles continued over control of centre of Az Zawiyah city.
August 19: Rebel troops seize Zlitan. Opposition source report more than 30 dead and 120 wounded in operations to further cut-off the capital from its supply lines. According to a Libyan government official, Hassan Ibrahim, the brother of Libyan government spokesman Moussa Ibrahim, was killed by gunfire from a NATO helicopter.
August 20: Tripoli revolts. Opposition cells in Tripoli supported by NATO launched an uprising codenamed "Operation Mermaid Dawn". Many of the weapons used by rebels had been assembled and sent to Tripoli by tugboat.Rebels suffered high casualties.
August 21: Rebel fighters enter Tripoli, reporting little resistance. Gaddafi makes two addresses over state TV, calling on Libyans to fight off the rebel "rats", and saying he is in the capital and will be "with you until the end". Rebels reach Green Square and rename it Martyrs' Square.
August 22: Gaddafi's son reappears. It was believed that Tripoli had largely fallen and there were reports that three of Gaddafi's sons were captured alive. Later in the day, however, Saif al-Islam Gaddafi showed up outside the Rixos Hotel, posed for pictures and a video and said his father's forces were still in control of the city. His re-emergence put earlier reports about his capture, and the rebels' hold on the city, in serious discredit.[
August 23: Battle for Tripoli rages on. Libyan rebels launch massive offensive on Gaddafi's compound. Rebel fighters mount an attack backed by captured tanks on the compound, in the centre of the capital. The sky was filled with the sound of heavy and light machine guns as well as mortars, with the overhead roar of NATO jets that have been carrying out much more intense air raids than in recent days.