The presidents of Egypt and Sudan have agreed to support the Libyan military in its fight against armed militias in the country following two-days of talks in Cairo.

Egypt's Abdel Fattah El-Sisi and his Sudanese counterpart Omar al-Bashir agreed to co-ordinate efforts to achieve stability in Libya through supporting state institutions, in particular the army, officials said.

The chaos in Libya is one of Egypt's main foreign policy concerns, following cross-border attacks by fighters who control parts of the country's east, including oil-rich Benghazi.

Meanwhile, Libya's new government has accused Sudan of arming "terrorist groups" operating on its soil, a charge Khartoum denies.

The two leaders said they wanted to move past recent strains in relations over divergent views over shared water resources and borders, with Bashir saying his country "sees eye to eye" with Cairo on many bilateral and regional issues.

A dam constructed by Ethiopia threatens to reduce Egypt's share of the Nile, challenging a colonial-era agreement that has given most of the water to Egypt and Sudan.

Sudan is not against the dam, while Egypt has been lobbying to reduce the impact of the project on its share of the river.

Ahead of his visit, Bashir raised the issue with reporters of the decades-old "Halayeb Triangle" border dispute between the two countries, saying Khartoum would not go to war over the issue but seeks to resolve the dispute.

"I assert now, after this second meeting with my brother president Sisi, there is a strong political will for the bilateral relations to move forward," Bashir said on Sunday.

'Ideological differences'

This is Bashir's first visit to Egypt since Sisi came to office in June, following the ousting of his predecessor Mohammed Morsi in July 2013. Morsi was an ally of Bashir and his party, the Muslim Brotherhood.

Despite the positive remarks, Hamad Omar Hawi, professor of political science at Khartoum North University, ruled out the possibility of a strategic alliance between the Sudanese and Egyptian governments due to "ideological differences".

The professor told Al Jazeera that the Ethiopian dam will continue to be an issue of dispute between the two leaders since Sudan is expected to "benefit a great deal" from it.
 
Meanwhile, Egyptian political analyst Rajab al-Bail told Al Jazeera that "for Egypt, the Nile's water is the cause of its survival, which is why Sudan is important for Cairo".

"On the other hand, Sudan is deeply keen on strengthening ties with Egypt, which is perceived as Sudan's northern gate, in addition to Cairo's regional and international leverage," he said.

Source: Al Jazeera and agencies