Three Saudi guards including a top commander were killed on Monday in a rare attack and suicide bombing by "terrorists" on the kingdom's border with Iraq, the interior ministry said.
Four attackers were also killed in the clash, two in suicide blasts.
No group claimed responsiblity for the clash, but Saudi Arabia is among countries that have joined the US-led coalition carrying out air strikes against jihadists from the Islamic State group in Syria and Iraq.
"A border patrol in Suwayf, in the northern Arar region, came under fire by terrorist elements," an interior spokesman said in a statement carried by the official SPA news agency.
As security forces killed one assailant, another "detonated an explosive belt he was carrying", killing himself and two guards and wounding another, the ministry said.
In a later statement, the ministry said a total of three guards were killed, including General Odah al-Balawi. Saudi media had reported that a senior commander of the border guard was among the dead.
Two assailants were shot dead and two detonated belts of explosives, the ministry said.
Saudi news website Sabq reported that Odeh commanded the border guards in the northern region.
The statement said the four were "trying to cross the Saudi border", but it did not clarify in which direction.
Saudi Arabia's top religious body, the Council of Senior Ulema, condemned the attack and reiterated its support for the government in its fight against extremist groups including IS and Al-Qaeda.
The head of the six-nation Gulf Cooperation Council, Abdullatif al-Zayani, also condemned "the terrorist attack on the northern border of Saudi Arabia".
In July, three shells fired from inside Iraq hit the Arar area, without causing any casualties.
Signup to our newsletter and follow us on Facebook and Twitter!
In 2013, Iraqi Shiite group Jaish al-Mukhtar claimed it had fired six mortar rounds into a remote area of northeastern Saudi Arabia as a "warning" to the kingdom.
- Securing the frontier -
Saudi Arabia shares a more than 800-kilometre (500-mile) border with Iraq and has recently stepped up efforts to secure the frontier.
In September, the kingdom inaugurated a multi-layered fence, backed by radar and other surveillance equipment, along its northern borders.
In November, Riyadh announced it had expanded a buffer zone along the border by 20 kilometres (12 miles).
The kingdom's participation in the US-led campaign of air strikes against IS in Syria has drawn threats of retaliation from the jihadists.
In a purported audio recording released on social media networks last month, IS leader Abu Bakr al-Baghdadi warned Saudi leaders they would see "no more security or rest".
Last month, Riyadh said it had arrested 135 suspects for "terrorism" offences.
The authorities said they had arrested three IS supporters for shooting and wounding a Dane in November.
A week after that attack, a Canadian was wounded in a stabbing while he shopped at a mall in Dhahran on Saudi Arabia's Gulf coast. Police arrested a Saudi suspect.
And in November, Saudi Arabia also blamed IS-linked suspects for killing seven Shiites, including children, in the kingdom's oil-rich Eastern Province.