Libya has expelled the Sudanese military attache after accusing Khartoum of flying weapons to Islamist rebels in Tripoli, raising fears of a widening regional conflict.

The government, which has fled Tripoli for eastern Libya, accused Khartoum of sending a transport plane loaded with munitions for the Islamist-led Libya Dawn militias who control the capital.

"Sudan is interposing itself by providing arms to a terrorist group that is attacking the headquarters of the state," said a government statement. "This also represents a clear violation of international resolutions, and the latest UN Security Council resolution."

The government said the plane entered Libyan airspace without permission on Thursday, making a refueling stop in the southern oasis town of Kufra, where the weapons were discovered. It said the weapons were destined for the Tripoli airport of Mitiga, controlled by Libya Dawn.

Sudan, which is sympathetic to Libya's Islamists, confirmed sending the plane but insisted the weapons were intended for legitimate border forces patrolling the southern desert.

"The plane did not carry any material for armed groups in Libya," Sudan's army spokesman al-Sawarmi Khalid told the local TV channel Shouruq, according to Reuters.

The incident has fueled fears that Libya's civil war, which has pitched an Islamist-led coalition against pro-government forces, is now drawing in outside powers. Last month Washington sources accused the United Arab Emirates and Egypt of bombing Libya Dawn forces in support of the Libyan government.

At the same time, Libya's western neighbours, Algeria and Tunisia, are reinforcing their borders after Tunisia's army captured a jeep loaded with weapons smuggled across the Libyan border last week.

Both states fear Libya's war will spill over their borders, with Algeria concerned about a possible repeat of the Islamist attack launched from Libya last year on its In Amenas gas plant which left 50 dead.

In Libya itself fighting continues between Islamists and their opponents in both Tripoli and Benghazi. Fierce rocket bombardments hit pro-government forces west of the capital, while air force jets bombed Islamist units who control much of Benghazi.

International mediators are scrambling to find common ground, with David Cameron's special advisor Jonathan Powell reporting back to Downing Street this weekend after meeting leaders of both sides in Libya last week.

But the room for compromise seems narrow. Libya now has two governments; the elected parliament, which has fled to the eastern city of Tobruk, and a Libya Dawn administration which controls Tripoli. The elected government has denounced Libya Dawn as "terrorists" while the rebels accuse the government of harboring former loyalists of Muammar Gaddafi.

The United Nations last week reported that 250,000 people have been displaced by more than three months of fighting, and warned militia leaders they face possible war crimes charges.

Libya is still subject to an international arms embargo imposed in 2011 during the uprising against the former dictator Muammar Gaddafi, with UN officials due to report on 15 September on any infringements.