It was the latest in a series of bombings and shootings linked to the Sunni extremist group in Saudi Arabia over the past year.
The murders, in the Qatif area of Eastern Province, came two days after the start of commemorations of Ashura, one of the holiest occasions for the Shia faith, a minority in Sunni-dominated Saudi Arabia.
“As (a) result of his shooting, five citizens… were killed, including a woman. Nine others were wounded,” an interior ministry spokesman said in a statement.
He said that at about 7:00 pm (1600 GMT) Friday a suspect with an automatic weapon “started to shoot randomly” at a hall used for commemorations in the Saihat area of Qatif city.
Police intervened and opened fire, killing the suspect, the spokesman said without giving details about the attacker.
“The situation is still under investigation,” he said.
State television earlier reported that the gunman was 20 years old.
A group calling itself Islamic State-Bahrain State claimed responsibility for the attack.
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.
A witness to Friday’s attack, Ali al-Bahrani, told AFP that “a gunman began randomly shooting at people attending a sermon”.
He said that a woman was killed.
Hussein al-Nemr, a local resident, said the shooting was one of three incidents on Friday evening.
– Security tightened –
Nemr, speaking from Saihat, said a gunman had stolen a taxi in neighbouring Dammam city, and a shooting also occurred at a mosque in Saihat but nobody was injured there.
“We are not sure yet if they are linked to each other,” he told AFP, adding IS had warned of attacks.
Since the start of Ashura commemorations, Shia security volunteers had been checking people at the entrances to houses of worship, Nemr said.
Security has been tightened at facilities since May when separate suicide mosque bombings killed 25 people.
Both attacks were claimed by IS, which considers Shia to be heretics.
Most Saudi Shia live in the oil-rich east, and many complain of marginalisation.
The Ashura commemorations — which peak late next week — mark the killing of Imam Hussein, the grandson of the Prophet Mohammed, by the army of Yazid in 680 AD. That event lies at the heart of Islam’s divide into Shia and Sunni sects.
IS, which has also targeted Saudi police, controls swathes of neighbouring Iraq and Syria where it has carried out widespread abuses.
Saudi Arabia and its Sunni Gulf neighbours last year joined a United States-led military coalition that is bombing IS in Syria and Iraq.
In July, the interior ministry 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, named 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.
“They are neither an Islamic state nor mujahedeen or Islamic mercenaries. Their faith is falsehood… their reality is bloodshed and looting.”