Saudi officials are hailing as a great success their rescue mission to free foreign workers held hostage by Islamic militants in the city of Khobar.
Saudi forces stormed the compound on Sunday morning
Interior Ministry officials said 41 hostages were freed, although at least 22 were killed in the 24-hour siege.
But the BBC's Middle East correspondent says Saudi officials are struggling with the embarrassing fact that most of the gunmen escaped.
One militant was captured, but three others evaded the security forces.
Manhunt under way
A statement from the interior ministry said the heavily-armed militants had managed to leave the compound by using hostages as human shields and then hijacking a car.
Their leader was left behind because he was wounded, the statement says.
One South African
Two Sri Lankans
A big manhunt is now under way in Khobar, with the police stopping traffic at checkpoints.
But the BBC's Middle East correspondent Paul Wood says this may do little to reassure the increasingly jumpy population of foreign workers in Saudi Arabia, for whom the 24 hours of terror represents another increase in the level of violence inside the kingdom.
The UK ambassador to Saudi Arabia says he believes that further militant attacks in the country may be in the final stages of preparation.
Sherard Cowper Coles said there was no intelligence about specific threats, but that a picture was emerging of scores of militants actively planning attacks of the kind seen in Khobar.
Britain is advising against all but essential travel to Saudi Arabia, but has not yet followed the US in telling its people to leave.
The Saudi Interior Ministry says the list of foreigners killed in Khobar include people from Britain, Egypt, India, Italy, the Philippines, South Africa, Sri Lanka, Sweden, and the US.
Twenty-five people of different nationalities were wounded, the interior ministry added.
A British woman was saved only because her local assistant stood in front of her and insisted to the gunmen that she was a Muslim.
Another survivor said some captives had tried to escape, but were caught and had their throats cut.
An audiotape posted on an Islamic website claimed this latest violence for al-Qaeda.
"We will cleanse the Arabian peninsula of infidels," the tape said.
A terrified survivor recalled how one of the militants, a man in his early 20s carrying a machine gun and wearing an ammunition belt told him: "We only want to hurt Westerners and Americans. Can you tell us where we can find them?"
The crisis began on Saturday, when the gunmen went on a shooting spree in Khobar, attacking company offices before moving on to the Oasis housing complex.
High risk gamble
On Sunday morning, commandos were dropped by helicopter onto the roof of the housing block and moved in.
It was a huge gamble, but Saudi officials had little choice as the gunmen had begun executing hostages, our correspondent says.
Our correspondent says that with oil at more than $40 a barrel, the attack is bad news for the world's economy.
He adds that by terrifying foreign workers in the oil industry, the militants are also undermining the ruling Saudi royal family - one of their stated aims.
Khobar, 400km (250 miles) north-east of Riyadh, is one of the centres of the Saudi oil industry, in which foreigners play a key role.
But despite this latest violence figures in the Saudi royal family say they are confident that they are winning the battle against al-Qaeda.