Now, however, he is campaigning for re-election on April 9, facing pressure from hawkish right-wing rivals — like Naftali Bennett, the education minister who wants to be defense minister — and a serious challenge from a new party, Blue and White, led by three former army chiefs.

Mr. Bennett, of the New Right party, demanded a plan to “defeat Hamas once and for all.”

“Not more shooting at sand dunes without causing harm to the enemy,” he said, “but time for an uncompromising pursuit and systematic neutralization of Hamas’s leaders.”

The justice minister, Ayelet Shaked, also of the New Right party, added her two cents on Twitter: “Two words — Bennett defense.”

And the leading challenger to Mr. Netanyahu, Benny Gantz of the Blue and White party, who as the army chief led the 2014 Gaza war, urged “a significant and sharp response, otherwise it will be impossible to renew deterrence.”

Hamas said Thursday that it would seek to punish those responsible for the Tel Aviv attack, suggesting that someone in one of the militant groups could have been acting in defiance of orders. In a statement, its military wing said, “We are not responsible for the rockets fired at the enemy tonight.”

Hamas has been in negotiations with Israel, through Egyptian intermediaries, for months, and it said that the rocket attack had occurred while its representatives were meeting with Egypt’s emissaries.

Palestinian Islamic Jihad, a more militant rival, is said to be impatient with the pace of those talks, and has at times used attacks on Israel to make itself heard. But a spokesman for Palestinian Islamic Jihad, Daoud Shehab, denied it had any role in the attack. “The factions have no intention to escalate,” he said.