By Tom Miles and Ahmed Elumami
GENEVA/TRIPOLI (Reuters) - Libya's warring factions who operate rival governments have agreed "in principle" to move future negotiations on ending the crisis from Geneva back to the war-ravaged country, the United Nations said on Thursday.
Some of the opposing factions met in Geneva earlier this week under U.N. auspices, but key representatives from the Tripoli-based government stayed away, demanding the dialogue be held within Libya.
"There was agreement on the principle of convening future dialogue sessions in Libya, provided that logistical and security conditions are available," the U.N. Mission for Libya (UNSMIL) said in a statement after another round of talks in Geneva. It gave no date or venue.
Libya, in turmoil since a NATO-backed revolt ousted Muammar Gaddafi nearly four years ago, has two rival governments and parliaments, each backed by armed factions which Western governments fear are dragging the oil-producing nation into full-blown civil war.
Underlining the precarious security situation, heavily armed gunmen on Wednesday stormed a luxury hotel in Tripoli, killing at least nine people, including foreigners, before blowing themselves up with a grenade.
Libya's internationally-recognized government under Prime Minister Abdullah al-Thinni and its elected House of Representatives are now based in the east of the country after a group called Libya Dawn seized Tripoli last summer, set up its own administration and reinstated the old parliament.
The Tripoli-based parliament, the General National Congress (GNC), welcomed the Geneva statement and said it would end a boycott of the negotiations declared after Thinni's forces seized a central bank branch in the eastern city of Benghazi.
Thinni's government said it was only "securing" the bank, which controls vital oil revenues.
The GNC's second deputy president, Saleh Mahzoum, said each side should now nominate four delegates for a resumption of the main political talks which began last September.
Despite the formidable obstacles in the way of forming a national unity government in Libya, diplomats brought members of Libyan city and regional councils together in Geneva on Thursday to discuss ways to end violence on the ground.
U.N. Special Envoy Bernadino Leon said the participants were working together "in very good spirits", even though many come from areas that are fighting each other. Despite their differences, they later posed for a group photograph and spontaneously sang the Libyan national anthem.
One delegate from Tripoli told Reuters the meeting had agreed to set up committees to build confidence by working together on abducted and displaced people, the media, airports and borders.
(additional reporting by Ulf Laessing and Stephanie Ulmer-Nebehay; editing by Patrick Markey and Gareth Jones)