CAIRO — Israel and Hamas agreed to a cease-fire on Wednesday after eight days of lethal fighting over the Gaza Strip, the United States and Egypt said after intensive negotiations in Cairo.