CAIRO — After three years of sporadic combat, the fighting is over in the eastern Libyan city of Benghazi, at least for now.

The city erupted in jubilation late Wednesday after the commander of a militia in the area, Gen. Khalifa Hifter, announced on television that his forces had vanquished the Islamist fighters they had been battling in Benghazi for the past three years. Wearing military-style regalia, General Hifter said that all that remained was to clear battle-scarred neighborhoods of land mines and unexploded ordnance.

Forces loyal to General Hifter, a brash and ambitious former Libyan Army officer, have prematurely claimed victory in Benghazi before. But this time residents said they believed that the news was genuine, with thousands of people streaming into the streets after his televised address to celebrate amid sounds of honking horns and triumphant gunfire.

If the peace holds this time it will be a milestone for General Hifter, who has emerged as the dominant commander in eastern Libya, with strong support from neighboring Egypt. It strengthens his hand in Libya’s chaotic power struggle, particularly against the rival government that is backed by the United Nations and based in Tripoli, the capital.