Thousands packed Tehran’s streets on Friday to mourn the victims of two suicide bomb and gun attacks, and joined their supreme leader in accusing regional rival Saudi Arabia of involvement in the assaults.

People in the crowds, some crying, chanted “Death to Saudi Arabia" alongside the more customary "Death to America" and slogans against Israel, as they reached out to touch coffins wrapped in flags and covered in flowers.

Bombers and gunmen killed 17 people in Iran's parliament and near the mausoleum of the Islamic Republic's founder, Ayatollah Khomeini, on Wednesday, in rare strikes on the capital that exacerbated regional tensions.

The Sunni Muslim militants of Islamic State claimed responsibility for the attacks on the Shi'ite Muslim state.

Iran's Supreme Leader Ayatollah Ali Khamenei, in a message read at the funeral, said the raids would increase hatred for Saudi Arabia, the region's main Sunni power, and America.

"It (the attacks) will not damage our nation's determination to fight terrorism ... but will only increase hatred for the governments of the United States and their stooges in the region like the Saudis," Khamenei said. Saudi Arabia has said it was not involved.

MORE ARRESTS

Mourners chanted "God is greatest" and some carried pictures of Khamenei, captioned: "We are ready to sacrifice our blood for you."

President Hassan Rouhani, a pragmatist more open to contacts with the West, attended the funeral alongside other clerics and officials. He said the attacks had targeted peace and democracy, but stopped short of blaming foreign powers.

The attacks came at a particularly charged time in the region, days after Riyadh and other Sunni Muslim powers cut ties with Qatar, accusing it of backing Tehran and militant groups.

The raids were the first claimed by Islamic State inside tightly controlled Iran, one of the powers leading the fight against the militants in Iraq and Syria.

Iran's Intelligence Ministry said on Thursday five of the attackers were Iranian nationals recruited by Islamic State who had fought in the militants' main strongholds in Syria and Iraq.

On Friday, the ministry said 41 suspects had been arrested around the country in connection with the attacks.

"With the help of security forces and families of the suspects, 41 people linked to the attacks and to Daesh (Islamic State) have been arrested in different provinces," state TV quoted the interior ministry as saying.

"Lots of documents and weaponry have been seized as well."

Two Sunni militant groups, Jaish al-Adl and Jundallah, have been waging an insurgency in Iran, mostly in remote areas, for almost a decade.