Libya's embattled prime minister, Abdullah al-Thani, said on Wednesday Egypt would help to train his army and called on compatriots to fight Islamist led-militias that have overrun the capital.
Thani and the majority of an internationally recognised parliament elected in June are in virtual domestic exile in the eastern city of Tobruk because of widespread security problems, including in Tripoli where a rival administration has been set up.
Egypt shares a long and porous desert border with Libya, and has backed Thani against the militias that seized Tripoli and are fighting for control of the airport in the country's second city Benghazi.
"We are facing terrorism," Thani told a news conference with his Egyptian counterpart, Ibrahim Mahlab.
"I call on all honourable citizens who refuse to be ruled by force to prepare to defend themselves. To die standing is better than to live humiliated," he said.
Thani, in Cairo for meetings with Egyptian officials, said they are aimed at "coordinating cooperation (with Egypt) on implementing a practical plan".
Signup to our newsletter and follow us on Facebook and Twitter!
That would include Egypt "training and improving the efficiency of the (Libyan) army," he said.
Libya has been sliding into chaos since longtime leader Moamer Kadhafi was toppled in an uprising three years ago, with interim authorities confronted by powerful militias that fought to oust him.
Thani's visit comes days after dozens of soldiers died in car bombings at Benghazi airport and in clashes with Islamists. The troops were loyal to a former general who launched a campaign in May against an Islamist militia in Benghazi.
Egypt and Algeria, which both border Libya, are concerned that the violence will spill over into their territories.
More than 20 Egyptian soldiers have been killed by militants in recent months in the west of the country, raising fears that Islamist insurgents battling the government in Cairo are seeking to open another front from the Libyan border.
And in August, the United States said Egypt and the United Arab Emirates secretly bombed Islamist militia positions near Tripoli's airport.
An Emirati official told AFP only that his country had "no reaction" to the claim, while Egypt's foreign minister denied any "direct" role by his country.