"I tried to unite Libyans and restrain foreign interference... but for health reasons, I can no longer continue with this level of stress and therefore I have asked the (UN) secretary-general to relieve me of my duties," Salame tweeted.
He added that he wished Libyans "peace and stability".
UN spokesperson Stephane Dujarric confirmed that Secretary-General Antonio Guterres had received a message from Salame "expressing his intention to leave his post".
"The secretary-general has always had full confidence in Mr Salame's work and the great efforts he has made to bring peace to Libya... (and) will be discussing with Mr Salame the way to ensure smooth transition so as not to lose any momentum on the gains that have been made," Dujarric told reporters in New York.
Salame's job had involved efforts to bring an end to years of turmoil since the 2011 overthrow of longtime dictator Moamer Kadhafi, which left Libya divided between rival governments and beset by violence.
His resignation comes after months of work to bring about a ceasefire since eastern-based military commander Khalifa Haftar launched an offensive in April to seize the capital Tripoli, seat of the UN-recognised Government of National Accord (GNA).
The unity government is supported by Turkey, while Haftar is backed by UN Security Council permanent member Russia -- two countries that also back opposing sides in Syria's conflict.
Salame, a former Lebanese culture minister, was appointed UN envoy in June 2017 and has struggled to unify Libyan ranks, organise elections and bring rival parties together for talks on ending the conflict.
Earlier this year the rivals agreed to a ceasefire brokered by Turkey and Russia that went into effect on January 12, but there have been repeated violations.
Political talks were due to start in Geneva last week but both sides refused to attend.
The talks were to run in tandem with military and economic negotiations as part of a UN-sponsored dialogue aimed at resolving the conflict.
On Friday, Salame lashed out at "cynics" he said were undermining the talks and said he needed "much more" international support, even as Tripoli's only working airport was hit yet again by rocket fire.
Salame warned of "almost a breakdown of that truce", adding that "many areas" of Tripoli were also hit.
Salame said he wanted a UN-facilitated process for political, military and economic talks between the two sides to continue even though they had both declined to attend the Geneva talks.
"We are pursuing our line despite the procrastination of these cynics," he said.
The international community had voiced its support for the UN-sponsored talks at a summit in Berlin in January.
"Did I get the kind of support needed since then?" Salame asked on Friday. "My answer is no. I need much more support."
Haftar's offensive to seize Tripoli in April came days before a UN-organised national conference to draw up a roadmap to elections in Libya meant to turn the page on years of turmoil.
But the conference was brutally postponed by the fighting and Salame told AFP at the time: "We worked for a whole year to prepare something unprecedented in Libya, that is a national conference that would bring everyone together.
"Now all these efforts have gone up in smoke."
Born in 1951, Salame spent most of his career as a professor of international relations at France's prestigious Sciences Po university in Paris.
He served as culture minister in Lebanon from 2000 to 2003 and later worked as an advisor to former UN secretary-general Kofi Annan and to the UN mission in Iraq.
He had taken up the post of UN Libya envoy from Martin Kobler of Germany, who had served from November 2015 until June 2017.
COMMENTS
Comments are moderated and generally will be posted if they are on-topic and not abusive.
For more information, please see our Comments FAQ