A suspected suicide bomber has died after blowing himself up near the United States consulate in Saudi Arabia's city of Jeddah, the interior ministry has said.

Security officers early on Monday became suspicious of a man near the car park of Dr Suleiman Faqeeh Hospital, which is directly across from the US diplomatic mission.

When they moved in to investigate, "he blew himself up with a suicide belt inside the hospital parking", the ministry said, adding that two security officers were lightly wounded.

The attack happened at about 2:15am (23:15 GMT) on July 4, the day when Americans celebrate their independence.

No one immediately claimed responsibility for the attack.

Later on Monday suicide bombers targeted mosques in in the cities of Medina and Qatif. Four people were killed in the attack in Medina, Islam's second-holiest city.

General Mansour al-Turki, the interior ministry spokesman, told Saudi-owned Al-Arabiya television that the bomber in Jeddah was not Saudi but a "resident foreigner".

Turki told state Al-Ekhbariya news channel that the suspect, in his 30s, was closer to a mosque in the area rather than to the consulate.

An investigation was ongoing, and some people were being questioned for their suspected links to the attack, security sources told Al Jazeera.

In a statement, the US consulate said there were no casualties or injuries among its staff, adding that it and the US embassy were in contact with Saudi authorities investigating the incident.

The US State Department also said that it was aware of the explosion in Jeddah and it was working with Saudi authorities to collect more information.

In 2004, five people stormed the US consulate in Jeddah with bombs and guns, killing four Saudi security personnel outside and five local staff within.

Three of the attackers were killed in the assault and two were captured.

In March last year the US embassy closed its main office, as well as consulates in Jeddah and Dhahran, for a few days over unspecified "security concerns".