Israel said it launched the offensive to protect itself against rocket attacks by the militant group Hamas .