The future of Libya's internationally recognised government was uncertain Wednesday after Prime Minister Abdullah al-Thani threatened to resign, but the latest UN-brokered peace talks ended amid optimism about a deal.
Thani made the threat during an emotional live television appearance in which he faced a barrage of angry questions from citizens.
However, it was unclear whether he intended to follow through.
His remarks added to the political uncertainty as Libya's rival factions met for a second and final day of talks in Geneva.
A UN statement said the talks had been held in a "positive atmosphere" and that there was optimism that the process was approaching its final stages.
The parties "underscored their determination to conclude the dialogue process as soon as possible", aiming for the coming three weeks, followed by adoption of a political agreement and formal endorsement at the "beginning of September".
Emhemed Shuaib, first vice president of the internationally recognised parliament, said: "I think we achieved good progress" and are in the "final kilometres".
He said talks could resume in Morocco near the end of this week.
- Citizen anger -
In a Tuesday night talk show, citizens blamed Thani's government for the lack of basic services such as electricity, and poor security in areas it controls.
"If my exit is the solution, then I announce it here," Thani said. "My resignation will be submitted to the parliament on Sunday."
But government spokesman Hatem el-Ouraybi said Thani's remarks had been conditional.
"The prime minister said during the interview that he would resign if people wanted him to. That's it," Ouraybi told AFP.
He said no resignation letter had been submitted to parliament.
"I don't now have an answer to the question of whether it will be submitted on Sunday."
Libya, which plunged into chaos after the ouster and killing of dictator Moamer Kadhafi in 2011, has two rival governments and parliaments vying for power, as well as several militia groups battling to control its oil wealth.
Signup to our newsletter and follow us on Facebook and Twitter!
Thani's government has been working out of the small eastern port of Tobruk near the Egyptian border since a militia alliance including Islamists captured Tripoli last year.
A partial peace deal aimed at restoring stability was reached last month, but leaders of the Islamist-backed General National Congress that sits in the capital boycotted the pact, calling it "unsatisfactory".
UN special envoy Bernardino Leon has urged the camps to reach a deal on a unity government that could enforce a ceasefire.
He laid out an ambitious timetable, calling for a comprehensive agreement before the next UN General Assembly meeting in September, although he warned the process would be difficult.
On Wednesday, representatives of both factions were seen in the same room with Leon a day after he told reporters he was meeting them separately but hoped to get everyone together.
Shuaib said: "This is positive; this is creative. This is the first time the congress (GNC) sat in on the meeting."
- 'Tension' over army chief -
Delegates say a key sticking point is any future role for controversial General Khalifa Haftar, installed by the Tobruk government as its army chief in March.
The 72-year-old Haftar served under Kadhafi before moving to the United States, where he worked at times with the CIA, according to US media reports.
He returned to Libya last year and took charge of the army, vowing to crush the Islamist militias while urging the West to support his forces.
Naeem Mohamed Abdurrahman al-Gheryani, a former education minister elected to the internationally recognised House of Representatives, said Haftar was clearly "the primary source of tension" at the talks.
"Him stepping aside will help remove a lot of anxiety and I don't think he is capable of being a being a unifying figure," Gheryani said.
He said "a lot of people" inside the internationally recognised parliament were unhappy with Haftar, "but don't think they are in a position to say that publicly".
Gheryani also dismissed Thani's resignation threat as inconsequential.
"The objective of these discussions is to form a national unity government, which hopefully will take over in a few months," he said.
"I don't think anybody cares about it."
Thani had already threatened to resign in April 2014, less than a month after being named to replace his sacked predecessor, after gunmen attacked his home in an incident that left no casualties.
In the end he stayed on, and was confirmed in the post by the parliament elected two months later.