An Interior Ministry spokesman said there were about a dozen militants in the city of El Kef and about 20 in the remote area of Mount Chambi in the west of the country where police and militants have clashed frequently in recent weeks.
According to a source at the Interior Ministry, who declined to be named, the Mount Chambi group was made up of nine Tunisians and 11 Algerians.
Algerian media, quoting unnamed security officials and locals in the border area, said the army there had been placed on alert since Monday to stop militants crossing from Tunisia.
Mokhtar ben Nasr, a spokesman for the Tunisian Ministry of Defense, told reporters that "the terrorists are still at the stage of preparing and storing weapons.
"They are seeking to turn Mount Chambi into the headquarters for their operations in the country. At Mount Chambi we found 16 arms caches being used by these groups and books, food and materials for making explosives."
An Interior Ministry spokesman said security forces had apprehended someone who was delivering food to the suspected militants at Mount Chambi, cutting them off from supplies.
Tunisia, long among the most secular countries in the Arab world, has become increasingly concerned about attacks the authorities blame on hardline Islamists.
Police say radical Islamists were behind the assassination of secular opposition politician Chokri Belaid in February, which triggered the biggest street protests in Tunisia since the 2011 overthrow of dictator Zine al-Abidine Ben Ali.
The threat posed by Islamist militants is also a regional one, with armed groups seen benefiting from lapses in internal security following the often chaotic transition from dictatorships to more democratic government.
An Algerian al Qaeda leader claimed responsibility for the January siege of an Algerian gas plant in which 37 foreign hostages were killed, and said it was in response to France's attack on allies in neighboring Mali the week before.
The town of In Amenas, where the attack took place, is located some 240 km (150 miles) south of Tunisia's southern tip.
Mount Chambi, Tunisia's highest point, is around 220 km southwest of the capital Tunis and just a few kilometers from the Algerian border. Conditions are rugged and most roads in the area are unpaved.