Israel and Hamas have agreed to a pause in their devastating two-year war and the release of the remaining hostages in exchange for Palestinian prisoners.