A senior commander in an armed group blew himself up and another was shot dead during a raid by Tunisian security forces on Sunday.
The men - suspected of having links with Islamic State of Iraq and Levant (ISIL) and al-Qaeda's North Africa branch (AQIM) - were planning attacks during the holy month of Ramadan, according to a spokesman for Tunisia's national guard.
The raid took place in Sidi Bouzid, a town 200km southwest of the capital, Tunis.
Another three people were detained and security forces were hunting for other suspects.
The group had been under surveillance for weeks after communications about a possible attack were intercepted, National Guard spokesman Colonel-Major Khelifa Chibani said.
"National Guard special forces killed two terrorists," he said. "They had been in the Sammama mountains and planned attacks during Ramadan."
One was a commander with the ISIL and AQIM linked group Okba Ibn Nafaa, he said.
The commander "was hit and blew himself up", according to Chibani.
The other man killed was also wearing an explosives belt, but was shot dead before he could detonate it.
Chibani did not give any details on the site of the alleged attack, but Tunisia has been on alert since gunmen hit the Sousse beach resort in 2015, killing more than 30 foreigners and badly damaging the vital tourist industry.
ISIL has claimed most of the major attacks in Tunisia.
Authorities say more than 3,000 Tunisians have left over the last few years to fight for ISIL and other armed groups in Iraq, Syria and Libya, and Tunisian authorities are trying to prepare for potential security threats upon their return.
Tunisia been under a state of emergency since November 2015, when a suicide bombing in Tunis claimed by ISIL killed 12 presidential guards.