A Kenyan court has freed a New Zealander held in police custody for several days on suspicion of links with extremism.

Sulub Warfaa, 36, spoke to journalists outside the court in Garissa, in northwestern Kenya.

"Just because I was born in Mogadishu does not mean that I am a terrorist," he said.

"I did not get tortured. The officers they were just doing their jobs, you know, that's what they were doing," said Warfaa, adding "I'm really happy that I am free, you know, and actually finally justice has been served."

Warfaa was arrested near Kenya's border with Somalia for allegedly possessing two passports with different names.

He was detained earlier this week with 10 other people in a sweep on suspected extremists near the Dadaab refugee camp, which houses at least 200,000 Somali refugees.

The crackdown followed an attack in January on a hotel complex in Nairobi in which 21 people were killed. The hotel assault was claimed by al-Shabab, Somalia's Islamic extremists who are linked to al-Qaida. The arrests were not directly linked to that attack.

Since 2011 Kenya has experienced several attacks by al-Shabab. The extremist group has vowed retribution on Kenya for sending troops to battle them in Somalia. Kenya is part of an African Union mission bolstering Somalia's fragile government from al-Shabab's insurgency.