The attempted attack — the latest targeting the Sunni-ruled kingdom’s minority Shiites — happened around sunset prayers on Tuesday, the ministry said in a statement.
Security officers “managed to foil a terrorist operation targeting worshippers” at Mustafa Mosque in Qatif, the ministry said.
When suspicious officers questioned the man, he tried to detonate a bomb in a sports bag on his back, leading the police to open fire.
The suspect died on the way to hospital.
Officers found four kilograms (8.8 pounds) of explosives in his bag.
“A search revealed a Pakistani ID which is still being confirmed,” the ministry said.
On July 4, a Pakistani resident of the kingdom blew himself up near the United States consulate in the Red Sea city of Jeddah, wounding two policemen.
It was one of three separate attacks throughout the kingdom that day.
One occurred at a Shiite mosque in Qatif, leaving the body parts of three people.
Near Islam’s second holiest site, the Prophet’s Mosque in Medina, four people died in another suicide blast.
No group claimed responsibility but CIA director John Brennan said the three bombings bore the “hallmark” of the Islamic State group of Sunni extremists.
Since late 2014 IS has claimed a series of bombings and shootings targeting Shiites in the Sunni-majority kingdom, as well as the security forces.
Dozens of victims were killed, largely in Eastern Province, home to most of the country’s Shiites.
Authorities arrested 19 people, including 12 Pakistani nationals, after the July attacks.
In another incident this month, a Yemeni accused of running over and stabbing a policeman in the southwestern region of Asir had pledged allegiance to IS, the interior ministry said.
IS group leader Abu Bakr al-Baghdadi has called for attacks against Saudi Arabia, which belongs to the US-led coalition bombing the jihadists in Syria and Iraq.
Last week the son of Al-Qaeda’s slain founder Osama bin Laden urged Saudis to “overthrow” the kingdom’s rulers in order to “free” themselves from US influence, SITE Intelligence Group reported.
Al-Qaeda waged a campaign of shootings and bombings against foreigners and Saudi security personnel between 2003 and 2007.