A coalition of armed groups has overrun a major Libyan army base held by allies of a renegade general in the eastern city of Benghazi.

Special forces troops of the Saiqa brigade, loyal to Khalifa Haftar, abandoned their base in southeast Benghazi on Tuesday after coming under attack, military officials and residents said.

"We have withdrawn from the army base after heavy shelling," Saiqa official Fadel al-Hassi told Reuters news agency.

The battle killed at least 30 people, according to agency reports.

We have withdrawn from the army base after heavy shelling. - Saiqa special forces official Fadel al-Hassi

Benghazi has suffered months-long battles between militias and forces allied with Haftar, who launched a campaign aimed at crushing what he calls "terrorists" and "extremists" including Ansar al-Sharia.

The official Twitter account of Ansar, a group inspired by al-Qaeda and dominant in Benghazi, posted that it had taken over the base.

In the fighting, a jet crashed after Haftar's forces launched attacks on groups including Ansar.

Mohammed Hegazi, a spokesman for Haftar's so-called National Army, claimed that the jet crashed due to a "technical failure" and that the pilot safely escaped.

The base's fall came as a ceasefire brokered late on Monday between Libyan militias in Tripoli was reportedly broken.

A shell has struck an oil depot tank in Tripoli's Sedi Bu-Salem district, an official with Libya's state-run oil corporation told the AP news agency. The tank did not catch fire.

The ceasefire agreement was made on Monday to allow firefighters to battle an out-of-control fire near Tripoli's airport, which was devastated by shelling between the militias that have controlled it since the fall of Muammar Gaddafi in 2011.

The confrontations have prompted many diplomats and foreigners, including the US ambassador in Libya, and staff from the UN and Canadian embassy, to flee the country.