Both sides in Libya's conflict agreed to a ceasefire from Sunday to end nine months of fighting following weeks of international diplomacy and calls for a truce by power-brokers Russia and Turkey.
The oil-rich North African country has been wracked by bloody turmoil since a NATO-backed uprising killed long-time dictator Moamer Kadhafi in 2011, with multiple foreign powers now involved.
Since April last year, the UN-recognised Government of National Accord (GNA) in Tripoli has been under attack from forces loyal to eastern-based strongman Khalifa Haftar, which days ago captured the strategic coastal city of Sirte.
Late on Saturday, Haftar's forces announced a ceasefire starting at midnight (Sunday 00:00 local time, Saturday 2200 GMT) in line with a joint call by Turkish President Recep Tayyip Erdogan and his Russian counterpart Vladimir Putin.
Early Sunday the head of the GNA, Fayez al-Sarraj, also announced his acceptance of the ceasefire, saying it had taken effect at the start of Sunday.
The UN mission in Libya welcomed the announcements and called on all parties "to respect the ceasefire" and to support efforts to launch an inter-Libyan dialogue.
Likewise, the Arab League called on Libya's factions to "commit to stop the fighting, work on alleviating all forms of escalations and engage in good faith aimed at reaching permanent arrangements for a ceasefire."
Since the start of the offensive against Tripoli, more than 280 civilians have been killed, 2,000 fighters have died and 146,000 Libyans have been displaced, according to the United Nations.
Sarraj stressed the GNA's "legitimate right ... to respond to any attack or aggression" that may come from the other side, while Haftar's forces warned of a "severe" response to any violation by the "opposing camp".
Artillery fire could be heard shortly after midnight in the capital, before quiet settled over the southern Tripoli suburb where pro-GNA forces have been resisting Haftar's offensive.
No ceasefire monitoring mechanism has been announced, but the GNA leader called for both sides to "prepare ceasefire measures under the aegis of the UN", without providing further details.
The ceasefire comes after a diplomatic offensive, led by Ankara and Moscow, which have established themselves as key players in Libya, supporting opposing sides.
Ankara deployed military support to the GNA in January. Russia has been accused of backing pro-Haftar forces, which are also supported by the United Arab Emirates, Saudi Arabia and Egypt, all regional rivals of Turkey.
Erdogan and Putin called for a truce at a meeting on Wednesday in Istanbul, and Turkey on Saturday asked Russia to convince Haftar, who had initially vowed to fight on, to respect it.
Fears of a 'second Syria'
Europe and North Africa have also launched a diplomatic offensive to try to prevent Libya, with the increased involvement of international players in its conflict, from turning into a "second Syria".
European governments, also including former colonial power Italy, are concerned that Islamist militants and migrant smugglers, already highly active in Libya, will take further advantage of the chaos.
The US embassy in Libya, in a statement Saturday, voiced its "serious concern about toxic foreign interference in the conflict".
It said "Russian mercenaries" had backed Haftar's Libyan Arab Armed Forces while "Turkish-supported Syrian fighters" had backed the GNA, a development that had "significantly degraded security, to the detriment of all Libyans".
It continued: "All responsible Libyan parties should end this dangerous escalation and reject the destructive involvement by foreign forces."
On Saturday Putin and German Chancellor Angela Merkel met in Moscow and called for international efforts to address the crisis in Libya.
Merkel said she hoped "the Turkish-Russian efforts will be successful," calling a ceasefire a first step in a peace process.
Putin and Merkel both backed a Libya peace conference in Berlin being organised by UN special envoy to Libya, Ghassan Salame, which could be held in the coming weeks.
Putin on Saturday again denied Russia had deployed mercenaries to Libya, saying: "if there are Russians there, they do not represent the interests of the Russian state and do not receive money from it."