Israel's national rescue service said at least 40 people have been killed and hundreds wounded, making it the deadliest attack in Israel in years.