In the weeks leading up to Hamas’s Oct. 7 attacks on Israel, hundreds of the Palestinian Islamist militant group’s fighters received specialized combat training in Iran, according to people familiar with intelligence related to the assault.

Roughly 500 militants from Hamas and an allied group, Palestinian Islamic Jihad, participated in the exercises in September, which were led by officers of the Quds Force, the foreign-operations arm of Iran’s Islamic Revolutionary Guard Corps, the people said.

Senior Palestinian officials and Iranian Brig. Gen. Esmail Qaani, the head of Quds Force, also attended, they said.

More than 1,400 people, mostly civilians, were killed Oct. 7 by Hamas fighters who poured across the border from the Gaza Strip. Scores of others were kidnapped and taken back to Gaza, where they are being held hostage.

Hamas attackers used aerial drones to disable Israeli observation posts and high-tech surveillance equipment. Some used paragliders to fly into Israel. Others rode on motorcycles, commonly used by Iranian paramilitary groups but not by Hamas until Oct. 7.

U.S. officials said Iran has regularly trained militants in Iran and elsewhere, but they have no indications of a mass training right before the attack. U.S. officials and the people familiar with the intelligence said they had no information to suggest Iran conducted training specifically to prepare for the events of Oct. 7.

On Wednesday, Israel’s military offered some of its most blunt comments yet on Iran’s role in aiding Hamas and other militant groups.

“Before the war, Iran directly assisted Hamas with money, training and weapons and technological know-how,” said Rear Adm. Daniel Hagari, the military’s chief spokesman. “Even now, Iran is helping Hamas with intelligence.”

Since the Hamas attack, Israel has waged a major air campaign, striking thousands of targets in Gaza and has been preparing for a ground campaign. The country has said its aim is to dismantle Hamas, and end its rule in Gaza.

The conflict risks spilling over into a regional confrontation with Iran and the web of anti-Israel Islamist militant groups that it backs, which spreads from Yemen and Iraq to Syria and Lebanon. And the U.S. has moved forces, including two carrier battle groups, into the region.

Israel and the U.S. have sought to highlight Iran’s role in supporting Hamas and other groups hostile to Israel, including the Lebanese Shiite militant group Hezbollah, which has been engaging in sporadic exchanges of fire with Israeli troops on Israel’s northern border.

But, with the specter of a wider war looming, the U.S. has said it has no evidence that Iran was directly involved in planning or approving the Oct. 7 attacks.

The Wall Street Journal, citing senior Hamas and Hezbollah officials, has reported that the Quds Force helped plan the attack and agreed that it could go ahead at a meeting in Beirut on Oct. 2 with leaders of Hamas and Hezbollah. An adviser to the Syrian government and a European official gave the same account of Iran’s involvement.

These accounts of the Oct. 2 meeting have been disputed by senior U.S. officials and others familiar with intelligence surrounding the attacks. Several U.S. officials said Washington has “compelling” intelligence indicating that Iranian leaders were surprised by the Hamas assault.

“The information that we have does not show a direct connection to the Hamas attacks on Oct. 7 as it relates to Iran. Again, that’s something that we’ll continue to look closely at,” Pentagon spokesman Air Force Brig. Gen. Pat Ryder said last week.

Hamas officials have boasted of Iran’s support since the attacks. “Hezbollah and Iran supported us with weapons, expertise, and technology,” Khaled Meshaal, a senior Hamas official in Doha, said in an interview with Al Arabiya.

As the attacks started on Oct. 7, according to Western and Egyptian officials, Hamas contacted IRGC and Hezbollah officials abroad to inform them that the assault had started.

Since then, the IRGC, Hezbollah, Hamas and other militias in the region say they have been in close contact to coordinate their activities. Quds Force commander Qaani was in recent days in Lebanon to consult with Hamas and Hezbollah officials, militant leaders and an IRGC adviser said.

The IRGC reports directly to Iran’s Supreme Leader Ayatollah Ali Khamenei. It operates independently of Iran’s elected government and its conventional military, with its own navy and business operations.

Iran has long provided training to militants across the Middle East, including Gaza militants, Afghan mercenaries who fight in Syria, Hezbollah fighters from Lebanon, Shiite forces from Iraq and the Houthis from Yemen, said Saeid Golkar, an IRGC expert at the University of Tennessee at Chattanooga.

“This sort of operation is very difficult to do without Hezbollah and IRGC support. Hamas does not have the capability to do that,” Golkar said.

Norman Roule, who was the top U.S. intelligence official for Iran from 2008-2017, said the IRGC has long been involved with training, funding and supporting groups in the region, but said that didn’t mean Iran directed the Oct. 7 attacks. “Rarely is it necessary for Iran to involve its personnel,” he said.

Hamas, an Islamist offshoot of the Sunni Muslim Brotherhood, has had an up and down relationship with Iran, a Shia Muslim theocracy.

The Revolutionary Guard backed Hamas as the Palestinian group emerged as an important militant organization fighting Israel in the 1980s, providing weapons and funding, European and Israeli officials have previously said.

The relationship broke down around 2012 when Hamas sided in the Syrian civil war against President Bashar al-Assad, an Iranian ally. The Islamic Republic cut all funding to Hamas.

In 2017, Hamas said it was receiving funding again from Tehran. At that stage, the IRGC expanded its military support, providing training and components that enabled Hamas to assemble its own drones and missiles to target Israel.

-Warren S. Strobel in Washington contributed to this article.