"We are happy to be alive, we are happy this has ended," said Canadian-Pakistan national Qurat-Ul-Ain Sadazai as she and colleagues -- from Canada, Norway and the Philippines -- arrived in Nairobi by Kenyan military helicopter.
The two men and two women with the Norwegian Refugee Council (NRC) looked exhausted and were covered in dust after their three day ordeal, but managed a weary smile to reporters before they boarded buses and left the airport.
NRC said in a statement it was "relieved and pleased" at their release, naming them respectively as Steven Dennis, 37, Astrid Sehl, 33, Glenn Costes, 40 and Sadazai, 38.
Costes limped from a bullet wound to the leg, but the four appeared to be otherwise in good health after arriving from the southern Somali border town of Dhobley, where they been freed earlier on Monday.
"They were released by a joint force of Somali and Kenyan forces, during which one of the kidnappers was killed," Kenyan army spokesman Cyrus Oguna told AFP. Three others were arrested.
Mohamed Dini Adan, a Somali military commander in Dhobley, an area under control of Somali forces allied to Kenya, said the army had stopped the "kidnappers who were trying to hide and sneak past the army."
Somali forces heard reports the gunmen were heading for a dense remote forest some 25 kilometres from Dhobley, and rushed to hunt them down.
"Thanks to God we foiled their aims of taking the hostages into the forest," said Somali General Osmail Sahardid, who led the operation.
Residents in Dhobley said the local Ras Kamboni militia -- commanded by a former powerful Islamist warlord now allied to Kenya -- were also involved in the rescue.
Kenyan security forces scrambled military helicopters and aircraft after gunmen attacked the NRC convoy at around midday Friday in Dadaab, some 100 kilometres from Somalia, killing a Kenyan driver and wounding two others.
However, the aid workers' vehicle seized by the gunmen was found abandoned a few hours after the attack, and fears grew the gang had escaped with the hostages through the remote scrubland across the porous border into lawless Somalia.
Kenya, which invaded southern Somalia in October to attack Al-Qaeda-linked Shabaab insurgents, has troops some 120 kilometres deep into Somalia. However, the forces control only pockets of the vast territory.
"We are thankful to know that our four colleagues have been found and safely returned to Kenya. This is a day of relief for us and for the families of the abducted," the NRC chief Elisabeth Rasmusson said in a statement.
"Our thoughts go to the family of the NRC driver, Abdi Ali, who was killed during the attack on Friday, and to our two local employees who are currently undergoing treatment in hospital for injuries inflicted in the incident.
"The attack in Dadaab will stand as a tragic incident in NRC's history."
The kidnapping was the latest in a series of attacks in Dadaab, where gunmen last October seized two Spaniards working for Medecins Sans Frontieres (Doctors Without Borders). They are still being held hostage in Somalia.
The abduction of the Spaniards was one of the incidents that spurred Kenya to send troops and tanks into Somalia to fight the hardline Al-Shabaab whom Nairobi blames for abductions and cross-border raids.
On Sunday, gunmen killed 17 people in the worst attack in a decade that Kenya blamed on Al-Shabaab, with masked insurgents hurling grenades into two churches in the eastern garrison town of Garissa before firing guns into the congregation.
Al-Shabaab still control large parts of southern Somalia, despite recent losses to African Union troops, government forces and Ethiopian soldiers, who have wrested several key bases from the insurgents.