Libya’s Prime Minister Fayez Al Sarraj announced that he will step down by the end of October to make way for a new government to unite the North African country divided by war and foreign military interventions. Mr Al Sarraj, who leads the Tripoli-based government recognised by the United Nations, led the defence of the capital with Turkish military assistance against an offensive by forces allied to a rival administration based in eastern Libya. Both sides agreed to a truce in August. Mr Al Sarraj’s decision to resign came after the capital descended into political infighting between an uneasy alliance of politicians and militias that had united to stop the offensive led by Field Marshal Khalifa Haftar. He has also faced a protest movement against corruption and poor services in the country, which has been wracked by violence since a Nato-supported popular uprising in 2011 deposed the dictator Muammar Qaddafi, who was later killed. Libya's oilfields, its main source of revenue, have been closed since January by eastern tribes allied with Field Marshal Haftar. The rival Libyan administrations have been holding talks in Morocco and plan to meet next month in Geneva to agree on a new presidential council and elections. Mr Al Sarraj called on them to speed up their dialogue and appoint a new prime minister so that he could hand over power by the end of October. “I wish them luck. On this occasion, I announce to all my sincere desire to hand over my duties to the coming executive authority by no later than the end of October, given that the dialogue committee finishes its work and chooses a new presidential council,” he said in a pre-recorded televised speech. Mr Al Sarraj welcomed the "preliminary and promising recommendations" agreed upon during the Morocco dialogue, which outlined the process for forming a new presidential council and the appointment of a new head of government who would take office "peacefully". The talks, termed the "Libyan Dialogue", brought together five members of the Tripoli-based Government of National Accord and five from the rival parliament headquartered in the eastern city of Tobruk. Their discussions focused on appointments to head the country's key institutions, with the naming of the heads of Libya's central bank, its National Oil Corporation and the armed forces the main points of dispute. Morocco also hosted talks in 2015 that led to the creation of the GNA. Mr Al Sarraj's announcement spells the end of his five-year leadership over an unruly government that seldom managed to control more than disparate parts of the country. “This opens up the Government of National Accord internally for rivalries as to who will take over and who will represent western Libya” in the Geneva talks, Emad Badi, a Libya expert and senior fellow with the Atlantic Council, told Bloomberg. “He was always kind of a lame duck, this just cements it. Now he’s set a timeline for being replaced.” Mr Al Sarraj's resignation would be welcomed by Field Marshal Haftar and his regional backers. Turkey, however, has seen him as a partner who delivered on granting them access to gas-rich parts of the Mediterranean. In western Libya, Mr Al Sarraj has been accused by rivals of protecting unruly militias that have infiltrated security services. His supporters say that the militias need to be tackled patiently to avoid bloodshed.