CAIRO (Reuters) - Egypt has offered to train pro-government forces battling rival armed groups in Libya, stepping up efforts to eradicate what it says is a threat to its own stability from the anarchy engulfing its neighbour.
The offer was the latest sign of intervention by competing Arab powers in Libya - a haven for Islamist militants and close to becoming a failed state - while Western governments are preoccupied with Iraq and Syria.
Egypt is trying to reassert its regional authority on its own terms while also winning back the U.S. military aid suspended after Cairo cracked down on the Islamist Muslim Brotherhood.
Egyptian military officials and representatives of pro-government Libyan forces have met several times over the past two months in Cairo and the Mediterranean city of Marsa Matrouh, Egyptian security officials said.
An intelligence official, speaking on condition of anonymity, said "intelligence and training" assistance were on the table. The Egyptian government spokesman declined comment, but Ahmad Buzeyad Al-Missmari, spokesman of the Libyan General Chief of Staff, confirmed Egypt had offered training for troops.
President Abdel Fattah al-Sisi has called for decisive action against militants based in Libya, who Egypt says sneak across the border to help Ansar Bayt al-Maqdis jihadists attack Egyptian security forces in its Sinai desert near Israel.
"Egypt has more intelligence on where they (the Libyan-based militants) are, how many there are, what kinds of weapons they had available," the intelligence official said.
Egyptian security officials have said Ansar Bayt al-Maqdis -- the country's most dangerous militant group -- has contacts with al Qaeda offshoot Islamic State, now targeted by U.S.-led air strikes in Iraq and Syria after it swept through Iraq, executing those who did not declare allegiance.
Sisi, who has publicly backed but not joined the air strikes, said last month any global coalition against Islamic State should tackle an array of extremist groups, making clear his main concern lay closer to home.
Islamists in Libya with ties to the Muslim Brotherhood were hit by air strikes last month that U.S. officials said were staged by Egypt and United Arab Emirates.
The UAE has not formally responded to the allegations and Egypt publicly denied involvement in the bombings, which came against a background of U.S. concern some countries may see the war against Islamic State as a green light for other attacks.
With the influence of the Islamic State spreading among the North Africa-based Islamist militant groups which send jihadi fighters to Syria and Iraq, Libya's western neighbour Algeria also plans to train Libyan forces.
But deeper involvement by Egypt, to its east, brings in one of the biggest armies in the Middle East, seeking to patch up a reputation damaged by its overthrow last year of elected Islamist president Mohamed Mursi after mass protests against him.
In April, Washington restored some of the annual $1.3 billion military aid to Egypt it froze after the military takeover but analysts said human rights concerns meant relations remained cool.
LIBYA DIVIDED
Libya has been torn apart by the worst violence since the overthrow of Muammar Gaddafi in 2011.
The government and elected parliament have relocated to Tobruk in the far east since losing control of the capital, Tripoli, where a rival administration has been created by mainly Islamist-aligned forces from the western city of Misrata.
The government has accused Sudan and Qatar of seeking to arm groups ranged against it, allegations both states have firmly denied, and at the United Nations on Saturday, it asked the world for weapons to help restore security and rebuild its institutions so it does not have to "face terrorism alone".
An Egyptian national security official who spoke to Reuters said the country would not give arms. "Weapons in Libya are like rice," he said, suggesting they were already abundant.
Some of those weapons are smuggled across the border and end up in the hands of Ansar fighters, security officials say. "Security forces are catching smugglers everyday," said the national security official.
Others come from dealers in Sudan who place them on boats that travel the Nile then unload in Egyptian towns, the officials said.
"Militants are paying for these weapons, for example, by robbing armoured cars going from Cairo to banks in Alexandia and Sharm al-Sheikh," the national security official said.
Western countries are particularly concerned by the presence of Islamist militant group Ansar al-Sharia in Libya, which the United States blames for killing its ambassador and three other Americans in 2012 and classifies as a terrorist organisation.
The stakes are also high for Egypt, a strategic U.S. ally which has a peace treaty with Israel and controls the vital Suez Canal global shipping lane but which has been unstable since a popular uprising ousted autocrat Hosni Mubarak in 2011.
Sisi crushed the Muslim Brotherhood after removing them from power as army chief last year, but hardcore Islamist insurgents have defied security crackdowns and killed hundreds of security forces, damaging the country's vital tourist trade.
Sisi has told the head of Libya's parliament that Cairo would fully support efforts to achieve stability in the oil-producing country.
Egyptian fears deepened after Libya-based Islamic militant gunmen killed 21 Egyptian military border guards in July.
Officials say Cairo has no intention of intervening directly in the conflict but two national security officials say Egypt considered launching a cross-border offensive several months ago. It was not clear what had become of that idea.
ISLAMIC STATE
The Egyptian security officials highlighted what they said were links between militants in both Libya and Egypt and Islamic State, saying Libyan-based Egyptian militants dream of creating an Islamic State-style empire in their homeland.
An Ansar commander told Reuters last month that Islamic State was coaching his group on how to create secret cells and evade capture, links affirmed by security officials.
Islamic State recently urged Egyptian militants to carry on with attacks on security forces and beheadings a day after a bomb attack beside the Egyptian foreign ministry in Cairo claimed by a militant group killed three policemen.
"There's a relationship between Libya's militants, Islamic State and Sinai militants. They have ideological ties and say they're together," said the intelligence official. The message conveyed by Islamic State was 'If you need anything or want to draw on our experience let us know,'" he said.
The national security official said there were signs Islamic State may be expanding its relationship with Ansar, citing a captured Ansar militant as telling his Egyptian interrogators an Islamic State fighter in Iraq had contacted him and sent money.
That account could not be independently confirmed. Washington has designated Ansar a terrorist organisation, but said in April it generally maintained a local focus.
Libya's military consists of former soldiers from the Gaddafi era and rebels who helped topple him who are now being integrated by the defence ministry. But political turmoil is delaying attempts by foreign partners to train up a proper army.
Aside from offering to train pro-government Libyan forces, Cairo is also willing to do business with former Libyan army general Khalifa Haftar in order to push back the militants, the intelligence official said.
Haftar emerged as a renegade commander fighting Islamists but has recently entered into a frail alliance with the government in Tobruk, part of the chaos and ever-changing alliances in post-Gaddafi Libya.
"Egypt told Haftar they could help him against the militants in Derna. That their locations could be provided and that his men could be trained on how they can fight them," said the intelligence official.
Egyptian security officials are especially alarmed over militants operating in and around the Libyan city of Derna, an Islamist and al Qaeda hotspot a few hundred kilometres away from the border.
Libya's neighbours and European nations have been trying to bring the waring parties together to find a political solution. Algeria said it was willing to host a reconciliation conference.
Algerian police are planning to train 60 Libyans as a first move to help it handle its domestic security and the Algerian gendarmerie has also been involved in training efforts with Libyan security forces, a security source told Reuters.
But the programme has faced difficulties because of the lack of interlocutors in Libya, the security source said, and Algerian officials say a political solution is the only way to get lasting stability.
(Reporting by a Reuters journalist whose name was witheld for security reasons, additional reporting by Lamine Chikhi in Algiers and Ulf Laessing in Tobruk; writing by Michael Georgy; editing by Philippa Fletcher)