BENGHAZI, Libya — Islamic State militants were retreating Thursday from their main bastion in Libya, as militiamen allied to a U.N.-brokered government pushed into the central city of Sirte, officials said.

Some militants reportedly shaved off their beards to escape while the pro-government fighters, mostly from the western Libyan city of Misrata, pushed into the city center in their tanks and pickup trucks mounted with machine guns. At a main square, the militiamen dismantled the metal frame of what some Sirte residents had dubbed the "stage of horror" — a podium used by IS for public beheadings and extrajudicial killings during its reign of terror.

Videos circulated on social media show triumphant militiamen flashing victory signs and chanting "Allahu-Akbar" or "God is Great" as they drive around Sirte.

The capture of Sirte capped a month-long offensive by the Libyan militiamen to take the IS stronghold — it was the only major IS-held city outside Syria and Iraq, and was seen as a possible fallback option for the capital of its self-styled caliphate. The IS extremists are currently struggling to fend off advances on a number of fronts, including in the Iraqi city of Fallujah and the northern Syrian provinces of Aleppo and Raqqa.

In Libya, militiamen from the western city of Misrata have been the main fighting force for the U.N.-brokered unity government that was installed in Tripoli earlier this year. For nearly four weeks, the militiamen have been advancing from the west and south against IS. The extremist group dispatched suicide bombers against the militiamen, who lost dozens of fighters last month.

On Wednesday, the militias pushed deeper into Sirte, which lies in the central part of Libya's Mediterranean coastline. On Thursday, they reached the city's key Zafarana Square, where they dismantled the stage where Human Rights Watch says IS killed at least 49 people.

Misrata-based media official Ahmed Hadiya said his forces found sinks full of shaved-off beards and long hair inside a Sirte school taken from IS, suggesting that the militants tried to get rid of their trademark looks before fleeing.

× Fear of missing out? Sign up for the Early Bird Brief - a daily roundup of military and defense news stories from around the globe. Thanks for signing up. By giving us your email, you are opting in to the Early Bird Brief.

A militia commander, Ali bin Gharbiya, claimed in an audio message posted on Facebook that the victory against IS militants in Sirte was quick. "Except for a little bit of anti-aircraft fire, they immediately withdrew," he says.

The government forces next goal was the Ouagadougou gigantic convention center, another city landmark, Hadiya said.

The center was the late Libyan dictator Moammar Gadhafi's onetime favorite conference hall where he hosted lavish African and Arab summits. IS had turned it into its headquarters and held graduation ceremonies there for those who completed IS-organized courses.

"The Daesh are cornered inside and around the center," Hadiya said, using the Arabic language acronym for the Islamic State group. "Our forces are preparing ... to seize the center."

IS militants unexpectedly showed little resistance once the militiamen pushed into their bastion. This could signal either a tactical retreat or a reflection of the small size of IS fighters remaining inside the city — after Western officials have earlier estimated IS strength in Sirte to be over 5,000 men.

IS and other extremists have exploited the chaos that followed the 2011 overthrow of Gadhafi in a NATO-backed uprising, establishing strongholds just across the Mediterranean Sea from Europe. Libya meanwhile sunk deeper into turmoil, with the country's feuding factions splitting it into two parliaments and rival governments.

This year, Western nations have thrown their support behind the U.N.-backed government in hopes of ending the rivalry between authorities based in the capital, Tripoli, and in the country's far east.

According to Ziad Hadia, who represents Sirte in the parliament based in eastern Libya, more than 2,000 IS fighters are thought to remain in the city. Foreign fighters, mostly from Tunisia and sub-Saharan Africa, account for more than 85 percent of the fighters, he added.

The Western-backed unity government, in the absence of an organized and unified army, has depended on the Misrata militias, among the country's most powerful.

Meanwhile, another force that answers to army leader Khalifa Hifter, based in the country's east, has announced that it has deployed fighters south of Sirte. A third armed group, which has declared its loyalty to the U.N.-backed government, on Thursday took the town of Hawara, east of Sirte, from IS. The group has also taken other small towns located between Sirte and an oil-rich area in eastern Libya in recent weeks.

Hadiya said the assault on Sirte has cost the Misrata militiamen the lives of 130 fighters and that about 400 have been wounded. Among the fatalities were two former government ministers who took up arms to battle IS, Mohammed Sawalem and Abdel-Rahman al-Kissa.

Before he was killed in Sirte, al-Kissa said on his Facebook page that fighting IS was a "gift from God ... this is a sacred war."

Michael reported from Cairo.

Copyright 2016 The Associated Press. All rights reserved. This material may not be published, broadcast, rewritten or redistributed.