The deal was announced in the early hours of Sunday morning after a week of violent clashes.