MISHMERET, Israel — Israel and Hamas exchanged blows on Monday after a rocket launched from Gaza struck a house in central Israel, wounding seven people.

Prime Minister Benjamin Netanyahu of Israel said that he was cutting short his visit to the United States, with the rocket attack posing a new challenge to his bid for re-election just two weeks before Israelis go to the polls.

But the lack of enthusiasm for an all-out conflict was apparent on both sides. Just hours after the fighting began, Hamas announced that Egyptian mediators had succeeded in brokering a new, albeit fragile, cease-fire.

The Israeli military said that Hamas, the militant group that controls Gaza, had fired a long-range rocket at dawn that struck the pastoral village of Mishmeret, about 20 miles north of Tel Aviv.