The gunman, who opened fire at the al-Salam royal palace in the Red Sea city of Jeddah, Saudi Arabia, was killed by palace guards.
The attacker was identified him as Mansour al-Amri, a 28-year-old Saudi national.
According to the security spokesperson for the Saudi Arabia's Interior Ministry, the attacker opened fire on the western gate of Al-Salam Palace in Jeddah, killing two guard members and injuring three others.
The victims have been identified as Agent Sergeant Hammad bin Shallah al-Mutairi and First Soldier Abdullah bin Faisal al-Subaie, the Saudi Ministry said.
The gunman had driven up to the gate of the palace and opened fire on the guards.
An AK-47 and thee Molotov cocktails were found on his person after the attack, the al-Arabiya news agency reported.
More From This Section
Meanwhile, the U.S. Embassy in Saudi Arabia issued a security warning to American citizens in Jeddah over the attack.
"Due to the possibility of ongoing police activity, American citizens are advised to exercise caution when travelling through the area," the embassy warned in a statement.
According to the national security agency, the warning came after the Saudi Police raided hideouts of a suspected terror cell linked to the Islamic State group this week, killing two people and arresting five.