Libyans took to the streets in Benghazi on Tuesday, honking car horns and waving Libyan flags in celebration after army units, backed by civilian fighters, cleared a major part of this eastern city of Islamic extremists, following nearly two years of deadly fighting.

The rare celebration comes hours after troops earlier in the day pushed into the once populous district of al-Laithi, a stronghold of Islamic militias who withdrew within hours. Over the past days, the army had made important advances and on Monday took control of a strategic port and a hospital.

Later Tuesday, families displaced from al-Laithi flooded back into the district to revisit their homes while others first waited for soldiers to inspect their houses for booby traps.

Residents posted photographs on social networking sites, showing tearful mothers bowing on the ground in front of their houses. Others hugged their sons who returned from the front lines. Streets of al-Laithi were largely blocked by large containers and sand bags used as defenses. In some of the buildings, personal belongings of the militiamen and Islamic militants lay scattered about after they retreated hurriedly.

Benghazi is Libya's second largest city and was the birthplace of the 2011 uprising that toppled and killed Moammar Gadhafi. Since 2014, it has endured fierce battles as the city became divided between warring parties, with militias -- including al-Qaida and Islamic State affiliates -- one side and army commanders and local fighters who answer to army commander Khalifa Hifter and the internationally-recognized parliament on the other.

The fighting is still going on, especially in militia-controlled pockets in southern and western areas of Benghazi. Many parts of the city lie in ruins, with buildings levelled and their residents long gone.

The violence that has torn Benghazi is just a segment of Libya's overall turmoil and chaos. The country is split between two parliaments and two governments, each backed by an array of militias and tribes. The United Nations brokered a deal last year and a unity government is awaiting endorsement from the internationally-recognized parliament.

That vote is expected to help pave the way for a unified military action against Libya's Islamic State branch, which has taken control of the central city of Sirte and surrounding areas.