The killings, in Saihat in Eastern Province on October 16, come two days after the start of Ashura commemorations, a holy occasion for Shia Muslims.
A group claiming links to Islamic State (ISIS) said it carried out the attack.
The Saudi Arabian interior ministry said a gunman opened fire at random before police intervened and shot the attacker dead.
Later, a group calling itself Islamic State-Bahrain State said that one of its “soldiers” had attacked “a Shia infidel temple” with an automatic weapon.
The group warned that “infidels will not be safe in the island of Mohammed”.
Correspondents say the name of the group appears to be a reference to the historic area of Bahrain, which once encompassed parts of what is now Saudi Arabia.
Other, smaller attacks against the Shia community in the east of Saudi Arabia were also reported on Friday evening.
The minority Shia community in Saudi Arabia is increasingly being targeted. Most live in the oil-rich east, and many complain of discrimination.
In May, ISIS said it had carried out a deadly bomb attack outside a Shia mosque in the city of Damman.
A week before, more than 20 people were killed in the village of al-Qadeeh when an ISIS suicide bomber struck during Friday prayers at a Shia mosque.
That attack was the first to be claimed by a Saudi branch of ISIS.
Hardline Sunnis regard Shia Muslims as heretics.
Saudi Arabia, which is part of a US-led coalition against ISIS in Syria and Iraq, has previously been threatened by ISIS.
The Saudis are also leading a coalition of Arab states in an air campaign against Shia rebels in Yemen.
In the Ashura commemorations, Shias mourn the death of Hussein, a venerated grandson of the Prophet Muhammad.
Image source: Wikimedia Commons President-elect Donald Trump celebrated his election victory at the Ultimate Fighting…
Millions of voters across the US chose to return Donald Trump to the White House…
Donald Trump declares victory in the US election as he addresses jubilant supporters in Florida.…
Stocks around the world are rising as Donald Trump appears to be on the cusp…
Donald Trump has won Pennsylvania, North Carolina and Georgia and taken a lead over Kamala…
Quincy Jones, the celebrated musician and producer who worked with Michael Jackson, Frank Sinatra, Ray…