By Patrick Markey and Tarek Amara
ALGIERS/TUNIS (Reuters) - Libya's neighbours are again preparing for possible Western intervention in Libya, tightening border security and sending diplomatic warnings about the risk from hurried action against Islamic State that could force thousands refugees to flee.
As Islamic State has expanded in Libya -- taking over the city of Sirte and attacking oil ports -- so too have calls increased for a swift Western response to stop the group establishing a base outside its Iraq and Syria territory.
For Tunisia, Egypt and Algeria, sharing borders with Libya was already a security challenge as the country slipped into war between rival factions and allowed Islamic State to thrive five years after NATO strikes helped defeat Muammar Gaddafi.
Exactly what Western intervention is possible is still under discussion. But President Barack Obama has ordered security advisers to look to halt Islamic State, and U.S. officials say air strikes and special forces operations are options.
Italy's defence minister has said the West can not afford to let spring come and go without intervening, though most officials say they are pushing for a united Libya government first to ask for help on the ground.
North African officials back international attempts to bring Libya's factions together, but they worry they will pay the price in instability, refugees and militant counter attacks if an intervention happens without a government on the ground.
"Those countries who are envisaging a military intervention in Libya should before anything take into consideration the interests of the neighbouring countries," Tunisian President Beji Caid Essebsi said.
Tunisia's parliament speaker travels this week to Brussels to express the country's concerns over Western military action to his counterparts in the European Parliament.
In the years since Gaddafi fell in 2011, Libya has slipped deeper into chaos with two rival governments each backed by competing factions of former rebel brigades.
A U.N.-backed government of national accord is trying to win support, but is still awaiting parliamentary approval, and has yet to establish itself in the capital Tripoli.
Western officials and diplomats say air strikes, special forces operations are possible as well as an Italian-led "security stabilisation" plan of training and advising.
U.S. and European officials insist Libyans must invite help through a united government, but say they may still carry out unilateral action if needed. The United States and its allies are already carrying out air strikes against Islamic State in Syria and Iraq.
Political delays in Libya are testing patience, however, and worrying North African governments.
"The people who wanted to first form a government, are now the same people in a hurry for intervention," one North African diplomat said. "You need a unified action. If you are just planning air strikes, it won't get the results."
FALLOUT AND PREPARATION
Tunisia and Egypt face the most risk from Libya's crisis. Last year, Tunisian jihadists who trained in Libyan camps carried out two major attacks on foreign tourists in Tunisia.
More than 3,000 Tunisians have left to fight with Islamic State and other militant groups in Iraq and Syria, but Tunisian security sources say they believe many are returning to Libya.
Along the Libyan frontier, Tunisian authorities have built a 200-km (125 mile) barrier. Hospitals in Gafsa, Tataouine, Mednine and Gabes are prepared to receive wounded, and authorities have stockpiled supplies, officials say.
"These Tunisian fighters left here illegally and they know ways to cross back," a Tunisian security source said. "We are vigilant for when they try to escape here if the coalition attacks on Islamic State start."
Egypt has long urged the international community to help fight Islamist militancy in Libya. But Cairo has also been more circumspect about a full-blown Western military intervention.
Over the past 18 months, Egypt has ramped up border security and aerial surveillance and also carried out air strikes itself on Libyan militants. It has also relied on Bedouins whose familial links allow them to act lookouts on the border.
"This is a Libyan decision that no one should interfere with," Egyptian Foreign Minister Sameh Shoukry. "We hope that the Libyan government and the Libyan army ... will come out with something that will exclude the possibilities of intervention."
With its own bloody history from a war with armed Islamists in 1990s, Algeria has been a key partner in the Western campaign against Islamist militancy in the Sahel, but it is also keen to maintain its traditional policy of non-interference.
Algerian border security was already tight since Islamist fighters crossed over from Libya to help in a 2013 attack on Algeria's In Amenas gas field, where 40 oil workers were killed.
Last month, Algerian forces arrested seven Libyan militants near the border close to In Amenas, and the army frequently stops weapons smuggled from Libya. Citing security concerns, Algeria last month also suspended flights to Libya.
"A major war in Libya would have a negative impact, more refugees and security risks," said Smail Djouhri, an ex-colonel and lecturer in security at Algiers University. "Less Daesh in the region is also good news. A blow to them reduces their recruitment in North Africa."
(Additional reporting by Lamine Chikhi in Algiers and Lin Noueihed in Cairo; Editing by Alison Williams)