Iran’s senior leaders had been planning for more than a week for an Israeli attack should nuclear talks with the United States fail. But they made one enormous miscalculation.

They never expected Israel to strike before another round of talks that had been scheduled for this coming Sunday in Oman, officials close to Iran’s leadership said Friday. They dismissed reports that an attack was imminent as Israeli propaganda meant to pressure Iran to make concessions on its nuclear program in those talks.

Perhaps because of that complacency, precautions that had been planned were ignored, the officials said.

This account of how Iranian officials were preparing before Israel conducted widespread attacks across their country Friday, and how they reacted in the aftermath, is based on interviews with half a dozen senior Iranian officials and two members of the Revolutionary Guard. They all asked not to be named to discuss sensitive information.

Officials said that the night of Israel’s attack, senior military commanders did not shelter in safe houses and instead stayed in their own homes, a fateful decision. Gen. Amir Ali Hajizadeh, the commander of the Revolutionary Guard’s aerospace unit, and his senior staff ignored a directive against congregating in one location. They held an emergency war meeting at a military base in Tehran and were killed when Israel struck the base.

By Friday evening, the government was just beginning to grasp the extent of damage from Israel’s military campaign that began in the early hours of the day and struck at least 15 locations across Iran, including in Isfahan, Tabriz, Ilam, Lorestan, Borujerd, Qom, Arak, Urmia, Ghasre Shirin, Kermanshah, Hamedan and Shiraz, four Iranian officials said.

Israel had taken out much of Iran’s defense capability, destroying radars and air defenses; crippled its access to its arsenal of ballistic missiles; and wiped out senior figures in the military chain of command. In addition, the aboveground part of a major nuclear enrichment plant at Natanz was severely damaged.

In private text messages shared with The New York Times, some officials were angrily asking one another, “Where is our air defense?” and “How can Israel come and attack anything it wants, kill our top commanders, and we are incapable of stopping it?”

They also questioned the major intelligence and defense failures that had led to Iran’s inability to see the attacks coming, and the resulting damage.

“Israel’s attack completely caught the leadership by surprise, especially the killing of the top military figures and nuclear scientists. It also exposed our lack of proper air defense,” Hamid Hosseini, a member of the country’s Chamber of Commerce’s energy committee, said.

Hosseini, who is close to the government, said Israel’s apparent infiltration of Iran’s security and military apparatus had also shocked officials. Israel has conducted covert operations in Iran against military and nuclear targets and carried out targeted assassinations against nuclear scientists for decades as part of its shadow war with Iran, but Friday’s multipronged and complex attack involving fighter jets and covert operatives..

Iran’s supreme leader, Ayatollah Ali Khamenei, who has been moved to an undisclosed safe location where he remained in contact with remaining top military officials, said in a televised speech that Israel had, with its attacks, declared war on Iran.