Libya's government has insisted it is still in control of the worsening security situation, even as an al-Qaeda-inspired group vowed to fight troops loyal to a renegade general behind an attack on the country's parliament.

Gunmen launched an attack on the parliament in the capital Tripoli on Sunday and demanded its suspension and an airport in the Eastern city of Benghazi came under rocket attack early on Monday.

Later on Monday the al-Qaeda-inspired Lions of Monotheism Group said it would fight forces apparently loyal to a renegade Libyan general, Khalifa Hifter, after they attacked parliament and suspended its activities.

The Associated Press news agency reported that Libya's army chief had ordered the deployment of the group, compounding the issue voiced by Hifter of unofficial armed groups being used by the government to enforce laws.

Hifter is a one-time rebel commander who said the US backed his efforts to topple Muammar Gaddafi in the 1990s. He says his group is taking on some of Libya's most hardline groups, and blames the government for not doing more to tackle them.

Hours before the parliamentary suspension, members of an armed group backed by truck-mounted anti-aircraft guns, mortars and rocket fire attacked parliament, sending politicians fleeing for their lives as gunmen ransacked the legislature, the Associated Press news agency reported.

MPs were evacuated from the building in southern Tripoli as heavy gunfire erupted after a convoy of armoured vehicles entered the city from the airport road and headed for the GNC.

The attack reportedly killed two people and wounded more than 50.

Early on Monday, the violence escalated as unknown attackers fired rockets at Benina airport in Libya's second-largest city of Benghazi. Authorities had closed the airport on Friday for security reasons.

Libya has been struggling with chaos as its government, parliament and nascent armed forces are unable to impose their authority over brigades of former rebels and militias who helped oust Gaddafi in 2011 but now defy the state.

Saudi Arabia announced on Monday that it was closing its embassy and consulate in Tripoli and withdrawing all of its diplomatic staff, citing security concerns, the state news agency SPA reported.

General Mokhtar Farnana, speaking on a Libyan television channel on behalf of Hifter's group, said it had assigned a 60-member constituents assembly to take over for parliament.

Farnana said Libya's current government would act on as an emergency Cabinet, without elaborating.

Farnana, who is in charge of prisons operated by the military police, said forces loyal to Hifter carried out Sunday's attack on parliament.

He also said the attack on parliament was not a coup, but "fighting by the people's choice".

"We announce to the world that the country can't be a breeding ground or an incubator for terrorism," said Farnana, who wore a military uniform and was seated in front of Libya's flag.

Early on Monday morning, Libya's interim government condemned the attack on parliament and largely ignored the declaration by the general's group.

"The government condemns the expression of political opinion through the use of armed force," Salah al-Marghani, the justice minister, said in a statement.

"It calls for an immediate end of the use [of] the military arsenal... and calls on all sides to resort to dialogue and reconciliation."

'Extremists'

The attack came after an assault on Friday by Hifter's forces on hard-line religious armed groups in the restive eastern city of Benghazi that authorities said killed 70 people.

On Sunday, gunmen targeted Islamist politicians and officials Hifter blames for allowing "extremists" to hold the country at ransom, his spokesman Mohammed al-Hegazi told Libyan television station al-Ahrar.

Officials believe members of the al-Qaaqaa and Sawaaq militias, the largest in the capital, backed Hifter even though they operate under a government mandate. Al-Qaaqaa posted a statement on its official Facebook page saying it attacked parliament with Sawaaq because politicians supported "terrorism".

Parliamentary head Nouri Abu Sahmein earlier told Libyan television station al-Nabaa that parliament would convene on Tuesday.