Agreement to hand over border towns comes after more than 700 Isis affiliates escape camp