Suspected al-Shabaab militants briefly kidnapped a Kenyan government official on Thursday and five security personnel were killed in an operation to rescue her, security sources said.
Armed men seized Miriam El Maawy, the principal secretary in the Ministry of Lands and Physical Planning, around 4pm in eastern Lamu.
A joint security operation involving police and the military was launched and Maawy was rescued when the car she was in lost control and rolled while speeding towards the border with Somalia.
But a gunfight broke out between the kidnappers and security forces, during which four police or military personnel were killed along with Maawy's bodyguard, a senior police officer told AFP.
Kenya Defence Forces spokesman Joseph Awuoth confirmed Maawy had been rescued but gave no further details.
The Shabaab is fighting to overthrow the internationally backed government in Mogadishu but also carries out regular attacks in neighbouring Kenya, which has troops in Somalia as part of an African Union force.
The group has increased its attacks in recent weeks in Lamu, as Kenya prepares to go to the polls for its General Election on August 8.