Friday's attack in the Qatif area of Eastern Province was the latest in a series of bombings and shootings linked to the Sunni extremist group in Saudi Arabia over the past year.
A suspect with an automatic weapon "started to shoot randomly" at a Shia place of worship in the Saihat area of Qatif city in the evening, an interior ministry spokesperson said in a statement.
Five Saudis, including a woman, were killed and nine others were wounded, he said.
Read: Five killed in Saudi Shia shooting claimed by Islamic State
Police intervened and opened fire, killing the suspect, the spokesperson said without giving details about the attacker, adding that the shooting was being investigated.
A group calling itself IS-Bahrain Province said in a statement that one of its "soldiers", Shughaa al-Dosari, "attacked a Shiite infidel temple with an automatic weapon" in Saihat.
"Infidels will not be safe in the island of Mohammed," it warned.
Most previous attacks in Sunni-dominated Saudi Arabia have targeted the minority Shia community which often complains of marginalisation.
A video, allegedly of the attack, posted on YouTube showed terrified people, among them many children, running frantically for cover inside the place of worship while gun shots could be heard.
Ali al-Bahrani who witnessed the attack said that the gunman was shooting at random as worshippers attended a sermon.
The Ashura commemorations -- which peak late next week -- mark the killing of Imam Hussein, the grandson of the Prophet Mohammed, by the army of the Caliph Yazid in 680 AD. That event lies at the heart of Islam's divide into Shia and Sunni sects.
Read: Two dead in attack on Iran Shia worshippers
Jaafar al-Abbad, the uncle of the dead woman, Buthaina al-Abbad, 22, said she died a "martyr for the sake of her beliefs".
"She was about to graduate from university as a doctor. Now she is a martyr, and this is even better," he said.
"People are pouring in to congratulate her parents," said Abbad.
He echoed other Shias saying such attacks "will not deter us from continuing to observe our rituals".
Nasema al-Sada, an activist from Eastern Province, said that since the start of Ashura volunteers have set up checkpoints at the entrances to places of worship in coordination with authorities.
Residents from the city of Dammam, where Shias are not allowed to build places of worship, come to Saihat to attend sermons which take place regularly during Ashura, said Sada.
Read: Gunman opens fire on Saudi Shia gathering TV
Witnesses said the Shiaplace of worship known as a husseiniya and an adjacent mosque were both targeted in Friday's shooting.
"We demand more protection and a law that would criminalise sectarianism," said Sada. "We are living in a place made out of paper, which could catch fire any minute."
"People are angry. And these attacks will only make us more attached to our rituals," she said.
"They can't stop us from practising our beliefs."
Security has been tightened at Shia facilities since May when separate suicide mosque bombings killed 25 people.
Both attacks were claimed by IS, which considers Shia to be heretics.
During Ashura last year, gunmen killed seven Shia worshippers, including children, in the eastern town of Al-Dalwa.
The interior ministry said the unprecedented incident had links to IS -- which has also targeted Saudi police.
Saudi Arabia and its Sunni Gulf neighbours last year joined a United States-led military coalition that is bombing IS in Syria and Iraq where the extremists have set up an Islamic "caliphate".
In July, Saudi Arabia said it had broken up an IS-linked network and arrested more than 430 suspects involved in attacks and plots.
Earlier Friday, Saudi Arabia's top cleric, Grand Mufti Abdulaziz al-Sheikh, branded IS as an enemy of Islam.
"The reality is that they are shedding Muslim blood and destroying Islam. There is no good in them," he said during weekly prayers at the Imam Turki bin Abdullah mosque in Riyadh.
COMMENTS (2)
Comments are moderated and generally will be posted if they are on-topic and not abusive.
For more information, please see our Comments FAQ