Libyan strongman General Khalifa Haftar has agreed to abide by a ceasefire and said he was ready to participate in an international conference in Berlin on Sunday, Germany's foreign minister said.

Libya's UN-recognised government in Tripoli has been under attack since April from Gen Haftar's forces, with clashes killing more than 280 civilians and 2,000 fighters and displacing tens of thousands.

The leaders of the North African state's warring factions were in Moscow early this week at talks aimed at finalising a ceasefire orchestrated by Russia and Turkey.

"During my visit to Libya today, General Haftar made clear: He wants to contribute to the success of the Libyan conference in Berlin and is in principle ready to participate in it. He has agreed to abide by the ongoing ceasefire," German Foreign Minister Heiko Maas tweeted after talks in Benghazi.

After the Moscow talks, Gen Haftar had walked away without signing the permanent truce, sparking fears about the shaky ceasefire.