The battle for the coastal city, which was the last significant territory held by IS in Libya, cost the lives of hundreds of loyalist troops as well as an unknown number of IS fighters.
"Our forces have total control of Sirte," Reda Issa, a spokesman for pro-government forces, told AFP. "Our forces saw Daesh (IS) totally collapse."
Forces allied with the country's unity government launched an offensive to retake the city on May 12, quickly seizing large areas of the city and cornering the jihadists.
"Daesh has totally collapsed and dozens of them have given themselves up to our forces," said a statement on the loyalist forces' official Facebook page.
More From This Section
The capture of Sirte boosts the authority of the UN-backed Government of National Accord (GNA), which was launched in Tripoli last March but whose legitimacy is contested by a rival administration based in eastern Libya.
The United States started a bombing campaign in August at the request of the GNA to help local forces recapture the city, seized by jihadists in June 2015.
Libya descended into chaos following the NATO-backed ousting of longtime dictator Moamer Kadhafi in 2011, with rival administrations emerging and well-armed militias vying for control of the country's vast oil wealth.
The infighting and lawlessness allowed extremist groups such as IS to seize several coastal regions, giving the jihadists a toehold on Europe's doorstep.
The fall of Sirte - Kadhafi's hometown located 450 kilometres (280 miles) east of Tripoli - represents a major setback for IS, which has also faced a series of military defeats in Syria and Iraq.
"Losing it (Sirte) could cause a momentary loss of traction, but a lot will depend on what happens in Syria and Iraq and whether the ungoverned spaces in Libya will remain such," said Mattia Toaldo, a Libya expert with the European Council of Foreign Relations.
Toaldo said IS's failure to hold Sirte was due in part to the group's lack of resources in Libya.
"They didn't manage to seize any considerable source of revenue," he said. "What they found in the banks in Sirte was not comparable to what they found in Mosul, nor was there an equivalent weapons stockpile.