Four people have been killed in Dammam, a city in eastern Saudi Arabia, after a suicide bomber's explosives blew up in the parking lot of a Shia mosque, according to the kingdom's official news agency.

The Saudi Press Agency said the explosion occurred when the bomber was parking his car during Friday prayers at the entrance of the Imam Hussein mosque in the port city, home to a large Shia population.

The Islamic State of Iraq and the Levant (ISIL) group later claimed responsibility for the attack.

It said guards approached the car as it was parking and that the driver - disguised in women's clothing - detonated a bomb.

"Thank God, security authorities managed to foil a terrorist crime targeting worshippers," the agency said in a statement. It was unclear if the bomber was among the four dead.

A witness, identified only as Ahmed, told Reuters news agency he was with his family near the mosque when "a quick explosion" happened. He did not know the cause of the blast.

He said acquaintances at the mosque told him that an attendant was killed along with the bomber when he tried to prevent the bomber from reaching the house of worship.

The Dammam bombing came exactly a week after a suicide bomber attacked a Shia mosque in a village in Qatif province during Friday prayers, killing at least 21 people and wounding several others.

That attack was also claimed by ISIL.