The violence raged across the city 250 miles north-east of the capital, Riyadh, starting at about 6pm local time and continuing into the night, sending scared residents running for shelter.
An Interior Ministry statement said security forces were carrying out a security operation "against a number of elements affiliated to the 'deviant group'", a term used for al-Qa'ida's branch in this kingdom.
Dammam's Emir, Mohammed Street, was at the scene of the initial clashes, where one militant was killed and another severely wounded, who later died, the official said on condition of anonymity as he was not authorised to speak to the media.
State-run Saudi television showed images of what it said was the body of slain militant. The official said that an unknown number of militants fled the scene of the initial fighting to the nearby district of Hamra, where foreign companies are based.
Police evacuated residents from several buildings in the area before scores of heavily armed security personnel surrounded a building sheltering the remaining militants. Clashes broke out again one officer was killed, the official said. Saudi-owned Al-Arabiya satellite TV reported that militants fired a rocket propelled grenade and hurled hand grenades at security personnel and set one police vehicle on fire.
It was unclear if any of the militants either slain or holed up inside the building were on a list of 36 most wanted terrorists sought for terror attacks in the kingdom dating back to 2003.