It has been said that this attack on October 7 was Israel’s 9/11. Each was an almost inconceivable attack on a prosperous, high-tech nation—by enemies thought incapable of accomplishing such missions, who used hardly any technology at all—that changed history forever. Audacious. Inhuman. Unimaginable. But not, as it turned out, impossible.

On Saturday morning, a quiet nonworking day for Israelis on the holiday of Simchat Torah, 2,500 Hamas terrorists carrying assault rifles and rocket-propelled-grenade launchers swarmed across a supposedly impregnable high-tech border. They shot out the cameras and sensors and punched through in 29 locations using bulldozers, ladders, and wire cutters.

For more than an hour, the Hamas men were hardly challenged and certainly not stopped as they fanned out to Israeli communities and even army bases.

We’ve learned from Israeli sources that on Friday night, less than 12 hours before the invasion, the security agency Shin Bet and military intelligence conferred about increased Palestinian activity near the fence and a bit of intercepted information. But Hamas had gathered protesters there before. Though the Israel Defense Forces (I.D.F.) chief of staff was brought into the discussion, the decision was made not to cause any panic during a holiday weekend by suddenly adding armed patrols and helicopter flights.

A senior Israeli intelligence officer who asks not to be named tells us, “In the worst-case scenario, we thought that if another round of violence does erupt, it will be more of the same. We were wrong.” (A spokesman for Hamas this week boasted that they gave that impression intentionally to deceive and distract Israel.)

Over the years, when tiny groups of Palestinian fighters crossed the border—to attack a target or, often, to try to kidnap one or two Israeli passersby—they were invariably detected and usually shot dead with ease.

Since 2005, when they pulled their soldiers and settlers out of the Gaza Strip, the Israelis depended on their clear advantage over the Palestinians when it comes to technology and wealth. The Israelis had convinced themselves that Palestinian armed organizations were a low-level problem that could be handled by electronic surveillance, spies buried in their midst, and occasional raids by the I.D.F. and the domestic-security service Shin Bet.

Yet, all the while, Hamas was increasingly receiving money from Qatar and Turkey—ostensibly just for food, medicine, and civil servants’ salaries—even as Iran provided even more cash, smuggled weapons, and rocket technology, according to several Western intelligence agencies.

Just two weeks ago, Israel’s military was paying more attention to the West Bank, where violence between Palestinian militants and radical Jewish settlers has repeatedly flared. There is no doubt that the controversial, extreme right-wing Jewish nationalist ministers, brought into government last year to help a desperate Prime Minister Benjamin Netanyahu form a ruling coalition, are intent on keeping the West Bank forever in Israel’s hands and pressuring Palestinian inhabitants to leave.

The Israelis had convinced themselves that Palestinian armed organizations were a low-level problem.

The all-powerful Israeli intelligence machine with its three branches—the Mossad (focused on worldwide escapades and less relevant to Gaza), military intelligence (M.I.), and Shin Bet (the domestic-security agency)—totally failed.

M.I. has a special squad (Unit 504) responsible for recruiting spies among Palestinians and other nationals who are in Gaza. M.I. also operates the well-known Unit 8200, which uses breakthrough technologies to eavesdrop on Hamas communication lines, intercepting conversations and texts while also conducting cyber-attacks to steal information from Hamas computers.

Shin Bet (known to Israelis as “Shabak”) is also using both electronic and cyber measures that complement the agency’s long-standing task of recruiting and running agents to gather “humint”—human intelligence. Special forces also have conducted cross-border operations to plant electronic equipment and pre-positioned explosives, and, when possible, to assassinate Hamas commanders and leaders.

Less than 12 hours before the invasion, Shin Bet and military intelligence conferred about increased Palestinian activity near the fence.

In addition, the Israeli Air Force has patrolled the skies over Gaza 24-7, using mostly drones and observation balloons, but also fighter jets and even eye-in-the-sky Israeli satellites in low orbit. The I.D.F. thought it was watching nearly everything happening in crowded Gaza.

Another layer of intelligence gathering has involved cameras with night-vision sensors attached to the 25-mile border fence, which in some sections is a high concrete wall. The cameras and the sensors are deployed every half-mile or so and are linked to several command-and-control war rooms.

In a sense, the failure echoes what went wrong in the Yom Kippur War. In 1973, Israeli intelligence had pieces of information that war was on the horizon, but spymasters did a terrible job interpreting the signs.

This time, intelligence agencies once again appear to have misread clues. Secretary of State Antony Blinken, after meeting with Netanyahu and other Israeli officials, told CBS News, “It may well be not that they didn’t have something but that they didn’t interpret it—in what proved to be the right way.”

The civilian death toll is the worst the Jewish people have suffered in one day since the Holocaust, and Israel’s own pre-1967 territory was turned into a bloody battlefield for the first time since the country was established, in 1948. Israelis are desperate to know how this could possibly have happened.

Most Israelis and foreign observers are puzzled and ask how one of the best intelligence apparatuses in the world collapses overnight. We also posed the question to several senior intelligence officials, and they couldn’t provide any reasonable answer.

Yet much can be explained by one word: hubris. Israel’s most extreme and radical right-wing government, led by Netanyahu, as well as the I.D.F. and the security services, had a preconceived notion that Hamas is weak and not interested in risking a major military confrontation.

Israel was also relying on a $1 billion barrier that it built to encircle Gaza. The barrier goes dozens of yards deep underground and is fitted with sensors aimed to detect any movement under the surface. It was constructed as a measure against the tunnels that Hamas had dug in the past and that were used by Palestinian gunmen to infiltrate Israel.

Israeli generals and Cabinet ministers lived under the illusion that the barriers and fence were not penetrable. They forgot historic lessons that any fortified border can be either circumvented (the French Maginot Line in the Second World War) or stormed and destroyed (the Israeli Bar-Lev Line along the Suez Canal in the 1973 war).

This is exactly what happened to 2023’s Israeli defense line around Gaza. According to Israeli intelligence, Hamas planners and fighters were sent to Iran and Lebanon (exiting the Gaza Strip via tunnels to Egypt) to design war plans and receive training. As described by the Israelis, some Iranian ships and some smugglers in the Sinai were able to get weapons to Gaza, and the arms are mostly Russian-made.

Israel attributes that to the Ukraine war, alleging that as Iran sends its explosive-carrying drones to the Russians, they reciprocate by sending a wide range of military equipment to Iran. The Iranians then ship supplies to their regional proxies, Hamas in Gaza and Hezbollah in Lebanon and Syria.

“In the worst-case scenario, we thought that if another round of violence does erupt, it will be more of the same. We were wrong.”

Knowing that Israel was listening to almost every word spoken or whispered in Gaza, Hamas chiefs ordered their fighters to maintain complete silence so as not to leave any digital signature. Like Osama bin Laden’s al-Qaeda, they used couriers on motorbikes to communicate. According to public remarks by Hamas, information about planning and training for the attack was tightly compartmentalized.

And thus, using deception and under the cover of rocket salvos against the south and Tel Aviv, around 2,500 gunmen (the size of a brigade), equipped to their teeth with Russian gear (Kalashnikov assault rifles, mines, bulletproof vests, anti-aircraft Strela missiles), destroyed the cameras and swarmed out to more than 20 villages and kibbutzim and several military bases. In scenes reminiscent of ISIS, they came by land on motorbikes and on dozens of Toyota pickups mounted with machine guns.

Hamas also launched attacks from the air, using paragliders, and via the sea, sending underwater divers and motorized boats to land on Israeli beaches and storm the nearby villages. The only Israeli success in the first hour of the Hamas invasion was on the beaches. The female soldiers on duty, observing the cameras and sensors, detected the invaders. Israeli troops and navy units arrived and killed them.

It took four days for the I.D.F. to reclaim the area and clear it of Hamas intruders. Nevertheless, even now there could be Hamas terrorists who are hiding and may be activated.

Israel has shifted entirely to its counter-offensive phase. Its attitude is that the gloves are off. No mercy for Hamas.

The attack on Gaza began from the air, with bombs and precision-guided missiles pounding Hamas positions—even though alleged hiding places, command bunkers, arms depots, and rocket factories were hidden in high-rise apartment buildings, banks, and mosques. In prior mini-wars, Israel hesitated to hit some of those targets, preferring not to kill civilians, but this time vast neighborhoods in Gaza City were turned into fields of earthquake-like devastation.

The Israeli strategic goal is to kill as many Hamas terrorists as possible in order to decapitate its leadership and disarm Hamas as a military organization. To achieve this goal, Israel will most likely have to invade Gaza on the ground, a costly operation in which many I.D.F. soldiers might be killed. And even if Israel does invade Gaza, it’s not going to be an easy task.

Hamas casualties are already much higher than the 1,300 Israeli civilians and troops killed, murdered, and massacred by the Hamas invasion. Israel has also to consider that more than 150 of its citizens—ranging from babies to soldiers to grandmothers—are held in Gaza by Hamas and its smaller sister group, the Palestinian Islamic Jihad. Some of them are foreigners with dual nationalities, including American citizens. The Biden administration, which is fully supporting Israel, said that 27 Americans were killed in the war and others kidnapped.

The danger and risk don’t stop at Gaza’s gates. Hezbollah, the proxy of Iran in Lebanon, threatened to rush to help Hamas by opening a second front in northern Israel. Even as the I.D.F. focused on the south, skirmishes broke out with Hezbollah fighters who fired mortar shells and tried to cross into Israel.

And whatever the outcome of the already devastating Israeli pounding of Gaza, partial or total victory will not erase that basic question the country’s people will ask until it is answered: What went wrong on October 7?

Six months after the Yom Kippur War of 1973, Golda Meir resigned, as did her legendary defense minister, Moshe Dayan. This year, Benjamin Netanyahu was under immense pressure from protests sparked by his self-serving judicial reforms. Those are suspended for now, but it is hard to believe that Israelis will forgive him for their country’s worst security lapse.

Yossi Melman, a defense-and-intelligence analyst for the Israeli news organization Haaretz, and Dan Raviv, a retired CBS News correspondent, are the authors of Spies Against Armageddon and other books on Israeli intelligence. Melman is based in Tel Aviv; Raviv, in Washington