The agreement follows months of on-off negotiations brokered by Egyptian and Qatari mediators, with the backing of the US.