NAIROBI, Kenya -- Dozens of extremists attacked a Kenyan coastal town for hours, killing those who couldn't answer questions about Islam and those who didn't know the Somali language, officials and witnesses said Monday. At least 48 people were killed and two hotels were set on fire.



The assault in Mpeketoni began Sunday night as residents watched World Cup matches on TV and lasted until early Monday, with little resistance put up by Kenya's security forces. Cars and buildings still smoldered at daybreak.



Authorities blamed al-Shabab, Somalia's al-Qaida-linked terror group, who have vowed to carry out terror attacks to avenge the Kenyan military presence in Somali. Along with its Somali fighters, the group also has many Kenyan adherents.



Like the gunmen who attacked Nairobi's Westgate Mall last year, the Mpeketoni attackers gave life-or-death religious tests, a witness said, killing those who were not Muslim.



"They came to our house at around 8 p.m. and asked us in Swahili whether we were Muslims. My husband told them we were Christians and they shot him in the head and chest," said Anne Gathigi.



Another resident, John Waweru, said his two brothers were killed because the attackers did not like that the brothers did not speak Somali.



"My brother who stay next door to me were killed as I watched. I was peeping from my window and I clearly heard them speak to my brothers in Somali and it seems since my brothers did not meet their expectations, they sprayed them with bullets and moved on," said Waweru.



At the Breeze View Hotel, the gunmen pulled the men aside and ordered the women to watch as they killed them, saying it was what Kenyan troops are doing to Somali men inside Somalia, a police commander said on condition of anonymity because he was not authorized to share such details of the attack.



Kenya's top police commander, David Kimaiyo, said the death toll was 48. A police spokeswoman said authorities believe that several dozen attackers took part.



Mpeketoni is about 20 miles (30 kilometers) southwest of the tourist center of Lamu. Any tourism in Mpeketoni is mostly local, with few foreigners visiting the area. The town is 60 miles (100 kilometers) from the Somali border and 360 miles (600 kilometers) from the capital, Nairobi.



Kenya has experienced a wave of gunfire and explosive attacks in recent months. The U.S., U.K., France, Australia, and Canada have all recently upgraded their terror threat warnings for the country. U.S. Marines behind sandbag bunkers are now stationed on the roof of the U.S. Embassy in Nairobi.



The Interior Ministry said that at about 8 p.m. Sunday, two minivans entered the town. Militants disembarked and began shooting. Kenya's National Disaster Operations Center said military surveillance planes were launched shortly afterward.



Lamu is a UNESCO World Heritage Site and is the country's oldest continually inhabited town. The region saw a spate of kidnappings of foreign tourists in 2011 that Kenya said was part of its motivation for attacking al-Shabab in Somalia. Since those attacks and subsequent terror warnings, tourism has dropped off sharply around Lamu.



At least 67 people were killed in September when four al-Shabab gunmen attacked an upscale mall in the Kenyan capital, Nairobi. Kenya sent its troops to Somalia in October 2011.