Hamas has agreed to observe a 24-hour truce in Gaza after initially rejecting a similar Israeli offer, as fighting resumed over the weekend and the two sides wrangled over the terms of a lull that international diplomats had hoped could be expanded into a more sustainable truce.