A suicide bomber purportedly from an Islamic State affiliate unleashed the first terrorist attack in Kuwait in more than two decades on Friday, killing at least 27 people and wounding scores more in a bombing that targeted Shiite worshippers after midday prayers.

The bombing struck the Imam Sadiq Mosque in the residential neighborhood of al-Sawabir in Kuwait's capital, Kuwait City. It is one of the oldest Shiite mosques in Kuwait, a predominantly Sunni Arab nation where at least at third of the population is believed to be Shiite Muslims.

It was the third attack in five weeks to be claimed by a purported IS affiliate calling itself the Najd Province, a reference to the central region of Saudi Arabia where the ultraconservative Sunni ideology of Wahhabism originated.

The upstart IS branch had claimed two prior bombing attacks on Shiite mosques in Saudi Arabia that killed 26 people in late May. The group was unheard of until the first Saudi bombing.

The attack took place as worshippers were standing shoulder to shoulder in group prayer, according to one of the witnesses at the mosque, Hassan al-Haddad.

The explosion ripped through the back of the mosque, near the door, he said, adding that other worshippers behind him said they saw a man walk in, stand in the back with other congregants and detonate his device.

Another witness, Ahmed al-Shawaf, said he heard a man interrupt prayer by shouting "Allahu Akbar," or "God is Great" in Arabic, several times. The man then he yelled out something about joining the Prophet Muhammad for iftar, the dusk meal with which Muslims break their daytime fasting during the holy month of Ramadan, which started last week. Then, the blast came, al-Shawaf said.

The explosion took place near the end of a second prayer, which is traditional to Shiites and follows the main midday Friday prayer.

The Ministry of Interior said 27 people were killed and more than 200 wounded. Police formed a cordon around the mosque's complex immediately after the explosion, banning people from entering or gathering near the area. Ambulances could be seen ferrying the wounded from the site.

"We couldn't see anything, so we went straight to the wounded and tried to carry them out. We left the dead," said witness Hassan al-Haddad, 21, who said he saw several lifeless bodies.

A posting on a Twitter account known to belong to the Islamic State group claimed the explosion was work of a suicide bomber wearing an explosive belt. It said the attack was carried out by the Najd Province, which also claimed the Saudi bombings.

The Islamic State group regards Shiite Muslims as heretics, and refers to them derogatively as "rafideen" or "rejectionists." The IS Twitter statement said the bomber had targeted a "temple of the apostates."

Immediately after the attack, Kuwait's ruler, Emir Sabah Al-Ahmad Al-Sabah, who is in his mid-80s, visited the site of the attack. The Cabinet convened an emergency session later in the afternoon. Kuwaiti Justice and Islamic Affairs Minister Yaacoub al-Sanea condemned the attack in a statement carried by the official Kuwait News Agency.

But the attack also drew accusations from some Kuwaiti Shiites, who said that Kuwait's leaders should have been more pro-active in protecting Shiites, and that their response to the attack is too little too late.

Former Sunni lawmaker, Abdullah al-Neybari, said the Kuwaiti government "is not doing what it should be doing to fight extremism in the country. "

This is a wakeup call to fight harder," he said.

The last massive attack to take place in Kuwait was in 1983, when Iranian-backed Shiite militants from Iraq carried out bombings that killed at least five and wounded nearly 90.