The military said four Israeli soldiers were killed Friday in southern Gaza when an explosive detonated as they searched a Hamas compound in Khan Younis, causing part of a building to collapse.