GENEVA — The feuding leaders of South Sudan announced on Thursday that after several missed deadlines they had agreed to form a unity government in a bid to end the ruinous civil war they began soon after the country was formed in 2011.

South Sudan became the world’s youngest nation when, after decades of bloody conflict, it gained independence from Sudan in an internationally-mediated agreement.

But two years later, a civil war broke out when President Salva Kiir, who belongs to the majority Dinka ethnic group, fired his deputy, Riek Machar, who belongs to the Nuer ethnic group. That war has since cost an estimated 400,000 lives and ignited Africa’s biggest refugee crisis in years.

After talks in the capital, Juba, Mr. Kiir and Mr. Machar, his former deputy turned rebel leader, told journalists on Thursday that they intend to form a unity government by a Saturday deadline. They had missed two previous deadlines in May and November last year, which they had set as part of an initial peace agreement that they reached in September 2018.