By Aziz El Yaakoubi and Ahmed Elumami
SKHIRAT, Morocco/TRIPOLI (Reuters) - A renewed military offensive in Libya threatens international efforts to reach agreement in the next few days on a unity government and lasting ceasefire in the warring oil producing state, a U.N. envoy said on Friday.
The internationally recognized government of Prime Minister Abdullah al-Thinni said its troops had started a campaign to "liberate" the capital Tripoli held by a rival administration.
The capital was quiet, residents said. But television stations linked to the opposing sides gave conflicting accounts of who was in control of two towns west of Tripoli.
"If it is a major operation then it will clearly have an impact on the dialogue," U.N. Special Envoy Bernardino Leon said. "It will seriously question the possibilities to continue working in the coming days."
Western leaders say the U.N. talks are the only way to end the chaos in Libya, where two rival governments and armed factions are battling for control and Islamist militants have gained ground in the resulting mayhem.
Both sides have attacked each other with war planes in the past few days. But earlier on Friday, Leon had said he hoped the rival factions would soon come closer to reaching a deal.
"By Sunday, we would like to have these documents ready and, if possible, published," he told reporters in Morocco at the start of the latest round of negotiations.
He was referring to a framework deal not only on a possible government but also on local ceasefires for frontlines across the North African country.
Diplomats are under no illusions that moderates attending the talks for both sides will face difficulties in persuading hardliners to accept any deal.
Both sides face internal divisions and are dominated by former rebels who helped oust autocrat Muammar Gaddafi in 2011, but who now use their weapons to fight for territory.
Thinni's government, which has allied itself with army general Khalifa Haftar, said his forced launched an operation west of the capital "which kicked off the liberation of Tripoli city and its suburbs from terrorist bases."
"In the last days, we have seen more fighting, more air strikes... not only in Libya but also in the region," Leon said, referring to a militant attack in Tunis on Wednesday which killed 23 people.
"There is a sense of emergency so we believe this is going to be a decisive moment," he said. The two gunmen who attacked a Tunis museum trained at a jihadist camp in Libya, Tunisia said.
(Reporting by Aziz El Yaakoubi, Ahmed Elumami, Ayman al-Warfalli, Omar Fahmy, Ahmed Tolba and Ulf Laessing; Writing by Ulf Laessing; Editing by Dominic Evans)