The five suspects were shot dead by Kenyan forces as they tried to flee in the coastal town of Mpeketoni, said Kenyan police chief David Kimaiyo. Those detained include the owner and driver of the vehicle used in Sunday's attack.
The attack occurred Sunday afternoon as Mpeketoni residents watched the World Cup on television. Witnesses said armed men stole a van and drove around town, shooting at hotels, restaurants and the police station.
Somalia's Islamist al-Shabaab group claimed credit for the attack on Monday, saying it was carried out to retaliate for the presence of Kenyan troops in Somalia and the killing of Muslims. Kenya was among countries that sent troops to Somalia in 2011 to help defeat the militants.
A day later, on Tuesday, Kenya's President Uhuru Kenyatta claimed that al-Shabaab was not behind the attack and instead blamed "local political networks." The president offered no proof of his claim and did not specify what constituted "local political networks."
Analysts regard Kenyatta's remarks as a diversion meant to reduce blame for the government's inability to protect Kenyan citizens and its weakness in dealing with the Islamic militant group.