The government has blamed the Mombasa Republican Council (MRC) for the simultaneous dawn attacks in Nyali barracks and Malindi Administration Police camp.
In a posting on social media, the National Disaster Operation Centre said the attacks were driven by a terrorist agenda.
“An attempted entry into 77 battalion Mombasa and Malindi AP camp at 5.15 am was a coordinated MRC attack driven by the global terrorist agenda,” the posting said.
An MRC official has however distanced the group from the attacks.
Secretary-general Randu Nzai Ruwa expressed shock that anyone could raid a military facility.
A soldier was on Sunday early morning severely injured following a daring raid by a machete-wielding gang at the barracks.
Soldiers on sentry duties killed five attackers on the spot and another one in a nearby forest as he attempted to escape.
Mombasa County Commissioner Nelson Marwa said the gang of about 20 was armed with crude weapons. An unknown number escaped with gunshot wounds.
Gang members killed were all in black trousers, t-shirts and adorned blue head-bands.
In Malindi, gunmen attacked the Malindi Administration Police camp and destroyed property before they were repulsed.
The gang of more than 10 people, who were reportedly armed with guns, pangas and crude weapons, smashed tuk tuks, vehicles and attempted to burn the entire camp.
No one was injured in the 5.20 am incident that has raised tension in the resort town.
It is alleged that the gang had carried petrol and were planning to set ablaze vehicles and buildings in the camp.
Malindi deputy sub-county AP Commander Mr Fred Mwangi said quick response from the officers saved the camp from a deadly attack.