“We are at war,” Prime Minister Benjamin Netanyahu declared after Hamas fighters carried out harrowing attacks on Israeli civilians.

And Mr. Netanyahu has swiftly assumed the mantle of a wartime leader, rallying his people, mobilizing support on the world stage, assembling a war cabinet and massing the Israeli Army outside the Gaza Strip for what could be one of the largest, most perilous operations in its history.

Yet Mr. Netanyahu is, in some ways, an unlikely leader for an Israel on the brink of war. In his 15 years as prime minister, he has steadfastly resisted major military entanglements, preferring targeted airstrikes or special operations. His reluctance had, until this past week, made him something of a contradiction: a bellicose-sounding leader who has shied away from all-out war.

Despite years of warning about the threat from Iran, covert efforts to sabotage its nuclear program and even assassinations of Iranian scientists, Mr. Netanyahu never ordered a military strike on that country — a decision that relieved American officials, who urged him against doing it, even as it reinforced a view among some in the Obama administration that the Israeli leader lacked courage.

At home, Mr. Netanyahu has presented himself as an unflinching guarantor of Israel’s security, less by going into battle than by managing conflicts with the Palestinians, leaning on allies like the United States, opening lines to old enemies like Saudi Arabia and other Persian Gulf states, and falling back on tough talk.

“None of Israel’s major wars have been on his watch,” said Anshel Pfeffer, a columnist at the Israeli news outlet Haaretz, who wrote a biography, “Bibi: The Turbulent Life and Times of Benjamin Netanyahu.” “He’s never been quick to mobilize and send in the whole army, which is in line with his character and experience.”

Mr. Pfeffer said he once calculated the average annual number of Israelis killed in war under Israeli prime ministers. Until Oct. 7, when more than 1,300 Israelis were killed by Hamas, the number was lowest under Mr. Netanyahu. Several of his predecessors, from Menachem Begin to Ehud Olmert, have taken far bigger military risks.

“Every time they’ve had a conflict with Hamas, there’s been talk of a ground incursion, and he didn’t want to do it,” said Daniel C. Kurtzer, who served as American ambassador to Israel from 2001 to 2005 and now teaches at Princeton. “He didn’t want to be a prime minister who presided over X number of funerals.”

To be sure, Mr. Netanyahu has not hesitated to target Hamas when its rockets have rained on Israeli towns and villages. In 2014, he ordered a more limited ground operation into the Gaza Strip, which enhanced his reputation domestically as a protector, even as it subjected Israel to international criticism for an operation that, for all its limited nature, still killed an estimated 2,251 Palestinians in 50 days of fighting.

Mr. Netanyahu’s reluctance to go even further, these observers said, is rooted in both his risk aversion — a trait that has also influenced his go-slow approach to peace talks with the Palestinians — and his military training. Like most young Israelis, Mr. Netanyahu enlisted in the Israel Defense Forces after high school. He served in a special forces unit that carried out cross-border raids.

In a tragedy that looms large in the Netanyahu family lore, his older brother, Yonatan, was the only Israeli soldier killed in the Entebbe raid, a much-celebrated counterterrorism operation to rescue hostages on an Air France jet that had been hijacked by Palestinian militants and diverted to Libya, and later Uganda, in 1976.

Those experiences, analysts said, imbued Mr. Netanyahu with a bias for tactical strikes over large-scale army operations. That has translated into a calculation that, with periodic bombardments of Gaza — a strategy some have called “mowing the grass” — Israel could keep a lid on Hamas’s destructive capacity, as well as Palestinian tensions, without having to find a lasting political solution.

Instead, Mr. Netanyahu put his energy into trying to normalize diplomatic relations with Israel’s Arab neighbors, through the Abraham Accords and talks now underway with the Saudis. Such links, its supporters reasoned, would effectively bypass the Palestinians, making that conflict a manageable sideshow. The recent attacks showed both the limits and the unsustainable nature of this strategy.

The barbarity of the Hamas attacks on Israeli civilians has upended the risk calculus for Mr. Netanyahu, several experts said. A ground invasion that might once have seemed like a high-risk venture now appears to many Israelis as the appropriate response to the worst attack inflicted on the Israeli people since the state’s founding in 1948.

“In a sense, he’s diffused the responsibility on to the war cabinet,” said Mr. Kurtzer, who has known him since the 1990s. “It’s a national emergency, there’s a unity government, and there’s a high premium put on unity.”

But Mr. Pfeffer noted that Mr. Netanyahu had rarely built trust with the generals of the Israel Defense Forces, viewing them as potential political rivals. That will be tested in coming days by the war cabinet, which contains three former generals, including Benny Gantz, who nearly unseated him as prime minister in 2020.

After so many years in power, so many feuds and rivalries, and such a public outcry over his proposed overhaul of the Israeli judiciary, Mr. Netanyahu, critics say, will find it hard to remake himself as a Winston Churchill-like figure.

“He is a deeply polarizing figure, so he can’t wear the mantle of a unifying wartime leader,” said Daniel Levy, the president of the U.S./Middle East Project, a think tank based in London and New York. “I would not underplay the fact that the day after the war ends, it’s not going to be a happy place for him politically.”

The prospect of a public inquiry into the intelligence failures that allowed Hamas to carry out its assault looms over Mr. Netanyahu, Mr. Levy said, even if it has been set aside for the time being. For Mr. Netanyahu, waging a successful war, however difficult, could be one of the few political lifelines he has left.

And yet he does not need to look far back in Israeli history to see the political risks of large-scale major military action. In 2006, Mr. Olmert, a newly elected prime minister, decided to order a major ground operation in Lebanon after the Islamic group Hezbollah fired rockets and conducted a raid in Israel, abducting and killing soldiers.

After 34 days of fighting, the United Nations brokered a cease-fire, leaving Hezbollah, which had been supplied by Iran, damaged but alive. Though Mr. Olmert claimed to have made gains for Israel, his popularity crumbled, there were calls for his resignation, and he faced a withering public inquiry.

In 1981, Mr. Begin faced intense criticism overseas for authorizing an airstrike that destroyed an unfinished nuclear reactor near Baghdad — an operation seen as a forerunner of a potential attack on Iran.

Other Israeli leaders, from Shimon Peres to Ariel Sharon and Ehud Barak, have struggled with the fallout from major military clashes. Mr. Netanyahu’s initial rise to power in 1996 was fueled in part by public anger over a wave of suicide bombings that occurred while Mr. Peres was in office.

Years later, when Mr. Barak served as defense minister in a coalition government under Mr. Netanyahu, he was viewed as more open than the prime minister to striking Iran to destroy its nuclear facilities.

Mr. Netanyahu warned repeatedly of the need to stop Iran’s uranium enrichment program by any means necessary. That rattled officials in the Obama administration, who feared that airstrikes would ignite a conflagration across the region. Yet he never won the full backing of the Israeli cabinet to order the strikes.

Some American officials said at the time that Mr. Netanyahu’s failure to pull the trigger, though welcome, was of a piece with his unwillingness to take risks in peacemaking. In 2014, Jeffrey Goldberg of The Atlantic quoted an unnamed senior administration official describing Mr. Netanyahu with an epithet that suggested he was chicken.

Angry Israeli officials speculated about how high-level the anonymous critic was. But even at home, some questioned whether Mr. Netanyahu ever planned to go through with it.

“The question is, was it convenient for him that he didn’t get enough support in the cabinet?” said Mr. Pfeffer, the biographer. “If Netanyahu was entirely determined to strike Iran, he would have done it.”