The issue or topic of Taqiya comes a lot so let me try to explain it from what my understanding has been while growing up as a Sunni Muslim. Sunnis and Shia's differ a lot from it. For over simplification of Sunni/Shia - Sunni/Saudi , Shia/Iran (easier to understand for people who aren't familiar):
Taqiya broadly refers to denial of religious belief in the face of extreme circumstances like in case of fearing death or extreme physical pain. Within the Sunni view the basic principle of taqiya is limited to interaction with non-Muslims only and when under compulsion. Within the Shia branch it takes a slightly different form as I know, it becomes a precautionary denial of religious belief or deception in the face of potential persecution. So that can be anything, it could or could not be fear of death. Shia jurists also allow it in interactions with Muslims and in all necessary matters. The main reason I think this happened in Shia Islam is because back in the day when Shia's were starting out they were being persecuted a lot by Sunnis for changing Islam and seen as heretics.
In Sunnism it is a case of under compulsion, fearing grave harm or death. And that called idtirar which means being forced. This is not just about concealing faith but also allows you to consume Haram/Prohibited food like pork to avoid starving to death. And lying about your faith under extreme conditions is kind of permitted as I said but not really under all circumstances, as said in Quran:
"If any one is compelled and professes unbelief with his tongue, while his heart contradicts him, in order to escape his enemies, no blame falls on him, because God takes his servants as their hearts believe."
This verse was revealed unto the prophet after Yasir was forced to recant his belief in the prophet and Islam by non-believers. Even then it is explained that concealing one's faith was justified if the person is in mortal danger but still martyrdom is considered more noble. The explanation that I have given you is what my parents and their sect believed in within Sunni Islam, which also believed that there shouldn't be any sect within Islam. Lying and deception only when you fear death and even then better not to. It also ties in with the concept of Niyya is Sunnism which the concept of intention. Merely performing an act without the right intention is considered insufficient.
Taqiya sort of loosely means to shield oneself. The Shia interpretation of it, which even some tactical Sunnis in the West have started using as well was not known to me till a later time in my age, when I had already left Islam. Again, I am no scholar, but the Shia interpretation of Taqiya is not supported in Quran unless you really stretch it out to mean something that it really doesn't. So Taqiya in the form that most think of in the West, is a strictly Shia practice. I have come to know that it actually a big part of their practice as they had to consistently hide their version of Islam from Sunnis who were in control during those times.
Now a lot of counter terrorism experts have asserted that this is used to deceive people in the West to the true intentions of the Islamists and they use it as a strategy. Of course, I am sure they are right about it. Islamists are probably using Taqiya along with the teachings that you should convert non-believers with your actions so that they see you acting piously which will make them become attracted to your faith. So while non-Islamists might be using the latter understanding for attracting people to their faith, Islamists are probably using a more strategized version of Taqiya to infiltrate. Especially if they can justify, the whole interaction with the West as a form of a long cold war then they can apply the Shia understanding of Taqiya to achieve their end goals. But I do have to emphasis that 99% of the normal Sunni Muslims do not know about it or have that kind of understanding of it. Which is probably why Islamist extremists are able to manipulate and recruit the Sunni youths from within their ranks.
The hadith goes: "There is a consensus that whomsoever is forced into apostasy and chooses death has a greater reward than a person who takes the license [to deny one's faith under duress], but if a person is being forced to eat pork or drink wine, then they should do that [instead of choosing death]."
I must emphasis at the end that I am not a scholar. This is only from my understanding. Hope it helps.
Great explanation Momus.
I am reading 'The Critical Qur'an ' (Robert Spencer. 2021) at the moment .It does much to explain the concept of Taqiyya.
"We smile in the face of some people although our hearts curse them"
(Abu Ad- Darda as noted by Al - Bukhari.)
"If you( Muslims) are under their (Infidels) authority, fearing for yourselves, behave loyally to them with your tongue, while harbouring inner animosity for them"
(Tabari )