The United States and Iran have agreed to halt their latest hostilities in the Gulf and resume negotiations for a comprehensive treaty, raising hopes that a fragile interim peace arrangement can survive despite days of escalating military exchanges.