President Trump had formalized an agreement between the two nations this fall, after weeks of conflict that threatened to lead to war this summer.