Gunmen first stormed then suspended Libya's parliament on Sunday in an anti-government rebellion that is spreading across the country.

Members of a militia allied to the renegade general, Khalifa Hiftar, hit the building with anti-aircraft guns and rockets, causing MPs to flee in panic as parts of the complex caught fire.

They then suspended parliament and said it would operate on an emergency basis.

A commander in the military police in Libya read a statement announcing the suspension on behalf of a group led by Hiftar, a one-time rebel commander who said the US backed his efforts to topple Muammar Gaddafi in the 1990s.

General Mokhtar Farnana, speaking on a Libyan television channel on behalf of Hiftar's group, said it wanted the 60-member constituent assembly to take over but on Sunday night the assembly leader, Ali Tarhuni, rejected the offer. Farnana said Libya's current government would act on an emergency basis, without elaborating.

Farnana, who is in charge of prisons operated by the military police, said forces loyal to Hiftar carried out the attack. He also said it 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 stood in front of Libya's flag.

Libya's interim government condemned the attack in a statement released early on Monday morning. The Libyan justice minister, Salah al-Marghani, said that Libya "condemns expression of political opinion with armed force".

He said Hifter's recent offensive in Benghazi had nothing to do with the attack but did not elaborate further.

The attack followed three days of fighting in the eastern capital, Benghazi, between Hiftar's forces and pro-government militias that have left 70 dead. Thick smoke billowed from the headquarters of the national congress building after the attack by a militia from Zintan.

Fighting later spread to other areas of the capital with tank and anti-aircraft fire heard in western districts.

Witnesses said gunmen smashed offices and furniture in the congress building, and President Nuri Abu Sahmain later phoned a TV station to deny reports that he had been kidnapped.

Hiftar, who commanded rebel forces in the 2011 Arab spring uprising, insists he has the army behind him and has vowed to crush government militias he says are dominated by "terrorists." Sections of the armed forces have defected to the general, with his jets pounding militia bases in Benghazi.

The government, caught by surprise by the attack, has declared a no-fly zone over Benghazi, only to see air force units defy it to continue bombing attacks.

The prime minister, Abdullah al-Thinni, denounced the rebellion as a coup, and called Hiftar a criminal.

The former general, who served under Gaddafi before defecting to America in the 1980s, insists he is fighting to save Libya, and vowed to continue the offensive.

"This is not a coup against the state, we are not seeking power," Hiftar said. "Terrorism and its servants want it to be a battle, so may it be a legitimate one."

The fighting, the worst in Libya since the Arab Spring revolution of 2011, has spread across the country as army and militia units declare for the rebels or the government.

In eastern Libya tribal units and some defecting army formations have clashed with Islamist militias, and the government has closed Benghazi's international airport.

Congress is itself split between Islamists and non-Islamists, with bitter disputes over the election of a new prime minister, Ahmed Maiteeg, who Congress has still to confirm in office.

Meanwhile the US has put Marine forces on standby in Sicily, Tunisia has moved 5,000 troops to the border and Algerian commandos have evacuated their ambassador from Tripoli.