The clashes were the first since insurgents killed five Westerners in a shooting earlier this month in the Saudi oil hub of Yanbu, and the latest in the wave of violence in the kingdom.
There was no immediate word on casualties, but no expatriates were believed injured in the shooting which took place at around 1730 GMT outside the Kingdom City Compound.
"There was a commotion on the waste ground next to the compound. There were shots fired from there. The National Guard engaged them in a firefight," one source said.
The compound housed many Western expatriates.
A top al-Qaida leader in Saudi Arabia in a purported statement posted on an Islamist web site claimed one of the group's cell had carried out the shooting in Yanbu.
Saudi Arabia has been battling supporters of Usama bin Ladin and his al-Qaida network since May last year after a spate of bombings in the capital Riyadh killed 50 people, including foreigners.