A year ago, Israel suffered its worst-ever intelligence failure when Hamas launched a surprise attack, killing 1,200 people and taking around 250 hostages. Today, a wave of strikes against Hezbollah has Israel’s long-vaunted spies back on the front foot.

The turnaround reflects how Israel has invested its time and resources over the past two decades. Since fighting a war with Lebanon-based Hezbollah in 2006, Israel has rigorously prepared for another major conflict with the militant group—and potentially with its backer Iran.

Hamas, by contrast, was viewed as a far less potent threat. Even shortly before the Oct. 7 incursion from the Gaza Strip, top officials were dismissing signs of an impending attack. Last September, the Israeli military confidently characterized Gaza as being in a state of “stable instability,” and intelligence assessments concluded that Hamas had shifted its focus to stoking violence in the West Bank and wanted to limit the risk of direct Israeli retaliation.

Blindsided

“Much of our focus was on preparing for the confrontation with Hezbollah,” said Carmit Valensi , a senior researcher at the Institute for National Security Studies in Tel Aviv and expert on the Lebanese militia. “We somewhat neglected the southern arena and the evolving situation with Hamas in Gaza.”

A series of Israeli attacks in Lebanon over the past two weeks have left Hezbollah reeling—shocked by Israel’s abilities to penetrate the group and struggling to close the gaps. Thousands of Hezbollah pagers and walkie-talkies exploded virtually simultaneously on consecutive days last week, killing 37 and injuring around 3,000. Shortly afterward, an airstrike in Beirut killed a group of more than a dozen elite military leaders.

On Friday, Israel targeted what it described as Hezbollah’s main headquarters in a Beirut suburb.

Hezbollah’s security remains porous. On Tuesday, another Israeli airstrike in southern Beirut killed Hezbollah’s top missile commander.

The operations came almost two months after Israel demonstrated its penetration of Hezbollah by killing top commander Fuad Shukr, who had eluded the U.S. for four decades. He was killed by an airstrike on his apartment on the upper floors of a Beirut residential building, where he had been summoned by a phone call shortly before.

The intensified campaign by Israel’s foreign spy service, the Mossad, and military intelligence units devastated Hezbollah’s leadership and degraded its weapons arsenal. The country’s air force has followed up with a bombing campaign that hit more than 2,000 targets this week.

Israel’s military chief of staff said Wednesday that the stepped-up effort has been preparation for a ground invasion . The U.S. and its allies are pressing the two sides to pause the fighting , hoping to avoid war on another front or even a regional conflagration as the fighting in Gaza continues in its 12th month.

More than 600 people have been killed in this week’s strikes on Lebanon, and around 2,000 have been injured, the country’s health ministry says, adding to the heavy toll already in Gaza.

Israel’s success against Hezbollah compared with its failure regarding Hamas comes because the country’s security services are better at offense than defense, according to Avner Golov , a former senior director at Israel’s National Security Council who is now with MIND Israel, a national security advisory group.

“The core of Israeli security doctrine is to bring the war to the enemy,” Golov said. “With Gaza, it was totally different. We were surprised, so it was a failure.”

Israel has monitored the buildup of Hezbollah’s arsenal ever since the two sides signed a truce in 2006 after a monthlong war. At the time, many in Israel’s security establishment were disappointed with the army’s performance in the war, as it failed to significantly damage Hezbollah, which began rebuilding its position in the south.

The military, as a result, sought to better understand Hezbollah and throttle Iran’s military and financial support to the group, including via a campaign of airstrikes in Syria that became known as the “ war between the wars .”

In Gaza, by contrast, Prime Minister Benjamin Netanyahu adopted a strategy of containing Hamas in recent years, thinking the Palestinian group was focused on governing Gaza and wasn’t interested in a war with Israel. The two sides had fought a series of short conflicts following Hamas’s takeover of the Gaza Strip in 2007, and the group’s leader in the enclave, Yahya Sinwar , appeared to be more interested in improving the economic conditions of the Palestinian people.

There were signs the U.S.-designated terrorist group was planning an attack, including military exercises that foreshadowed the ways it stormed into Israel on Oct. 7.

But Israel’s intelligence services discounted the exercises as saber-rattling for Hamas’s domestic audience. The military felt confident in the strength of the technologically advanced separation wall it had erected to divide Gaza from Israeli territory.

Gathering intelligence from human sources that might have warned of an attack had become more difficult after Israel unilaterally withdrew from the Gaza Strip in 2005 and turned it over to Palestinian control, said Uzi Shaya , a former Israeli intelligence official.

“The ability to create human intelligence in Gaza in a very dense and small area, in which everyone knows everyone, where a stranger pops immediately, makes life much more difficult,” Shaya said. Getting access to people in Lebanon or outside Lebanon connected to Hezbollah is easier, he said.

Feats of intelligence only go so far. Ultimately, Israel’s success against either group will be determined on the battlefield. In the tight confines of the Gaza Strip, Israel’s military has battered Hamas and laid waste to the urban landscape. It will face a different enemy in the hills of Lebanon.

Despite Israel’s long effort to degrade Hezbollah’s military buildup, the Lebanese militia managed to amass a vast arsenal it can deploy in a war. The group is now weighing how to respond to the series of devastating Israeli attacks. Hezbollah fired its first missile ever at the commercial capital of Tel Aviv on Wednesday, its boldest response yet, but it hasn’t come close to implementing all its capabilities.

Valensi, the senior researcher at the Institute for National Security Studies, said there was a danger Israel’s recent successes leave it overconfident. Invading Lebanon with troops could give Hezbollah the opportunity to demonstrate its military advantage on the ground, she said.

“We saw how challenging and difficult it is to eliminate such a complex organization like Hamas,” she said. “Hezbollah is a different story.”