* Gas deal part of supply talks since early this year
* Five cargoes to be delivered by year-end
* Sisi, Algeria talk over security, Libya (Adds Cairo dateline, recasts lead, adds details throughout)
By Lamine Chikhi and Maggie Fick
ALGIERS/CAIRO, June 25 Algeria agreed to ship five cargoes of liquefied natural gas to Egypt before the end of the year, a source at Algerian state energy firm Sonatrach said, helping its north African neighbour with its worst energy crunch in years.
The offer of five 145,000 cubic metre cargoes was made after a visit by Egyptian President Abdel Fattah al-Sisi to Algiers, his first trip abroad since taking office. Sisi was seeking Algeria's support to counter Islamist militancy and cooperation on the chaos in neighbouring Libya.
"We did not reach a deal on pricing yet, but it is almost a deal," the source said of the agreement, which is part of talks over supplying Algerian gas for Egyptian power stations.
Egypt's oil ministry spokesman Hamdy Abdel-Aziz said he did not have any information on the status of the negotiations between the two countries, which began early this year.
The two north African countries both have long borders with Libya where, three years after the fall of Muammar Gaddafi, a weak central government is struggling to contain Islamist militants and brigades of former rebels and militias.
Sisi, who was in charge of the army when it forced Egypt's Islamist President Mohamed Mursi from power after mass protests, has been criticised by many countries for a heavy-handed crackdown on dissent. But Egypt's strategic position still makes it an important security partner for the West.
Egypt's steadily declining gas production and foreign firms' wariness about any increasing investment have combined with price subsidies and rising consumption to create the country's worst energy crisis in decades.
The country of 85 million relies heavily on gas to generate power for households and industry. Previously unheard of winter power cuts this year emphasised the extent of the crisis.
Egypt has been scrambling to secure natural gas supplies, which its mainly oil-producing Gulf Arab allies cannot provide. Saudi Arabia, the United Arab Emirates, and Kuwait have given $6 billion in petroleum products since the army ousted Islamist President Mohamed Mursi last summer.
Not all Gulf countries have been generous with the government after Mursi's ouster. Qatar, which backed the Brotherhood, sent Egypt LNG shipments last summer but negotiations for further supplies stalled over political tensions.
The total amount of those shipments was never made public. The cargoes helped Cairo meet its commitments to foreign companies after it diverted gas promised for export to meet soaring demand.
Egypt's Oil Minister Sherif Ismail said in March that negotiations with Algeria's Sonatrach were over "around 400 million cubic metres" of LNG, but the total agreed on Wednesday was far less, only 725,000 cubic metres.
Ismail told Reuters in February that Egypt needed to import an additional $1 billion worth of petroleum products and secure significant natural gas supplies to meet energy needs for the summer.
The minister has been outspoken about the need for energy sector reforms which could encourage wary companies to help the country develop its available reserves. Ismail frequently cites cutting fuel subsidies that strain state finances as a priority, although raising energy prices could trigger unrest.
While power cuts are not a daily occurrence in all parts of the capital, failure to find solutions to ease the worsening crunch could frustrate Egyptians, who rioted last year over long lines at petrol pumps just before the army ousted Mursi.
Egypt secured the means to import LNG last month, although a terminal will not be in place in time to ease the gas shortages this summer.
The oil ministry forecast last month that gas production would fail to meet surging domestic demand for the first time in the fiscal year beginning in July. (Writing by Patrick Markey; editing by Louise Heavens and Keiron Henderson)