Updated

Iranian leaders on Friday accused the United States and Saudi Arabia of supporting the Islamic State-claimed dual attacks that killed 17 people in Tehran this week, as thousands of Iranians attended a funeral ceremony for the victims.

The country's Supreme Leader said the attacks will add to the hatred that Iranians harbor toward the U.S. and Saudi Arabia.

In a condolence message ahead of a funeral for the victims, Ayatollah Ali Khamenei said the attack: "will not damage the Iranian nation's determination and the obvious result is nothing except an increase in hate for the governments of the United States and their stooges in the region like Saudi (Arabia)," state media reported.

On Thursday, Iran's Intelligence Minister Mahmoud Alavi said investigators were working to determine whether Saudi Arabia had a role Wednesday's attacks but said it was too soon to say if that was the case.

The Islamic State group has claimed responsibility for the attacks. The IS media arm Aamaq released a video Thursday evening showing what it claimed was a message from the Tehran attackers. The four-minute video shows three masked men sitting on a floor holding automatic rifles. One of the men speaks in the sorani Kurdish dialect common among Kurds in northeastern Iraq and northwestern Iran.

The speaker claims to represent the "first battalion" of IS formed inside of Iran. He speaks out at length against Shiites and promises further attacks. He concludes by threatening the royal family of Saudi Arabia and promises, "after Iran, it will be your turn."

During the funeral, Parliament Speaker Ali Larijani called the U.S. the "international" version of the Islamic State group and said Washington had exchanged democracy for money, a reference to a recent huge arms deal between the U.S. and Saudi Arabia. State TV broadcast the ceremony live.

He said anti-Iranian remarks by Saudi Arabia's foreign minister and U.S. President Donald Trump are a "matter of disgrace" for them.

Larijani also criticized a Wednesday decision by the U.S. Senate to move forward on a new set of sanctions against Iran, including its elite Revolutionary Guards, a move that came on the same day as the Tehran attacks.

During a massive funeral ceremony in Tehran following Friday prayers, thousands chanted "Down with the U.S." and "Death to Al-Saud," the Saudi royal family, while carrying coffins of victims.

The Vatican on Friday sent a message of condolence for the victims of the attack.

Pope Francis "laments this senseless and grave act of violence," and "assures the people of Iran of his prayers for peace," the message read.

As the funerals took place, Iranian authorities continued a widening crackdown. Iranian state TV said the Intelligence Ministry had detained 41 suspects in Tehran and the western Kurdish provinces of the country. The report called the detainees "elements of the Wahhabi IS group," and said they were involved in operations, communication and logistics for the local Islamic State cell.

The Intelligence Ministry said its forces stormed several "safe houses" linked to the group in the country's northwest, according to state television. Alavi told state TV that authorities had found and raided the home where the pre-attack IS video was filmed.

IS has long vowed to attack Iran because the country had deployed military advisers and support to both Syria and Iraq in their fights against the extremist group.

Although this is the first evidence of an IS presence inside Iran, the government has clashed in the past with both Kurdish Islamic militants and secular Kurdish separatists.

Last August, the government announced it had executed a number of Kurdish Islamic extremists from a group known as Towhid and Jihad after convicting them of armed robbery, killing civilians and planning bomb attacks.

Two guards, 10 government staffers and five civilians were killed in the attacks that simultaneously targeted the country's parliament and shrine of late founder of the Islamic Republic Ayatollah Ruhollah Khomeini. The Interior Ministry in a statement increased the number of wounded to 52, up from 40.

___

Associated Press writers Maamoun Youssef in Cairo and Frances D'Emilio in Rome contributed to this report.