BENGHAZI, Libya (Reuters) - East Libyan forces said they captured the final holdout of Islamist-led rivals in the southwest of Benghazi on Saturday, ending weeks of resistance by fighters camped in a cluster of apartment blocks.

The eastern-based Libyan National Army (LNA) has been waging a campaign in Libya’s second biggest city for nearly three years and still faces pockets of resistance in two northern neighborhoods, despite making big gains since early last year.

Milad al-Zwai, spokesman for the LNA’s special forces, said the siege at the “12 blocks” site ended when rival fighters tried to escape at dawn. He said 23 were killed and six arrested while seven LNA troops were killed and at least six wounded.

LNA spokesman Ahmed al-Mismari said as many as 40 of the LNA’s opponents had been killed. The figures could not be independently verified.

Dozens of family members had also been in the besieged buildings, where according to humanitarian groups they had run out of food and water.

Efforts to evacuate the families had largely failed. Mismari said six families were detained by the LNA and would be investigated. It was not immediately clear how many of the LNA’s opponents or their families had escaped.

The LNA also said it had lost a MiG-21 fighter jet over the Benghazi district of Sabri on Saturday, though the pilot had ejected. It still faces armed opposition in the northern neighborhoods of Sabri and Souq al-Hout.

Slideshow ( 3 images )

LNA leader Khalifa Haftar launched his Dignity Operation in Benghazi in May 2014, saying he wanted to rid the city of Islamist militants following a series of bombings and assassinations.

Some of his opponents have openly acknowledged their allegiance to Islamic State or al Qaeda-linked groups but others say they are fighting to prevent a return to authoritarian rule in Libya.

Haftar has rejected a beleaguered U.N.-backed government in Tripoli that was meant to reunite the country after it split between eastern- and western-based governments and military factions in 2014.

On Friday, there were demonstrations against militia rule in central Tripoli after unusually violent clashes this week, and some voiced support for Haftar before the protests were broken up amid gunfire.

Haftar, who many suspect of seeking national rule, addressed the capital’s residents on local TV after the protests saying, “your armed forces will not abandon you, and we will be by your side until Tripoli is returned to the homeland.”

A group of 22 militias based in Tripoli issued a statement on Friday reasserting their opposition to the LNA leader.