This is from another site (I read many hadiths, but to be brief here is one about the story of Ammar):
In the early days of the Prophet’s (SAW) mission there was much opposition to his message. This lead to several deaths, namely Sumayyah bint Khabbat, the first martyr of Islam. Her son, Ammar Ibn Yasir also faced serious threat, and in the end told his oppressors what they wanted to hear in order to save his life. A verse in the Quran was revealed regarding this issue :
16|106|Whoever renounces faith in God after having believed—except for someone who is compelled, while his heart rests securely in faith—but whoever willingly opens up his heart to disbelief—upon them falls wrath from God, and for them is a tremendous torment.
H 2244, CH 93, h 15
Ali has narrated from his father from ibn abu ‘Umayr from Jamil from Muhammad ibn Marwan who has said the following: “Once abu ‘Abd Allah, recipient of divine supreme covenant, said to me, ‘What was it that prevented Maytham (may Allah grant him blessings) from al-Taqiyyah?’ He by Allah knew that this verse of the Holy Quran was revealed about ‘Ammar and his people, ‘. . . unless he is forced, but his heart is confident with belief. . . .’” (16:106)
H 2239, CH 93, h 10
Ali ibn Ibrahim has narrated from Harun ibn Muslim from Mas’adah ibn Sadaqa who has said the following: “It was said to abu ‘Abd Allah, recipient of divine supreme covenant, ‘People narrate that Ali, recipient of divine supreme covenant, once said from the pulpit in al-Kufah, “O people, one day you will be told to abuse me. You then will do so, then you will be told to denounce me but you will not denounce me.” The Imam said, ‘How often has this falsehood (lie) been told about Ali, recipient of divine supreme covenant.’ The Imam then said, ‘What he said was: ‘One day you will be told to abuse me, you must do so then you will be told to denounce me, and I follow the religion of Muhammad, recipient of divine supreme covenant. He did not say do not denounce me.’ The person asking the question then asked, ‘Do you say he must have chosen being murdered instead of denouncing?’ The Imam said, ‘By Allah, there was no such thing necessary for him to do. There was nothing for him but that which happened to ‘Ammar ibn Yasir when people of Makkah forced him and his heart was confident with belief. Then Allah, the Most Majestic, the Most Holy, revealed His words about it, ‘. . . except those who are forced but their heart is confident with belief,’ (16:106) to which
the Holy Prophet said, ‘O ‘Ammar, if they would do such things again you also may do as you have already done; Allah, the Most Majestic, the Most Holy, has revealed His words about your good excuse and has commanded you to do again what you did before if they ever repeated their misdeed.’”
28لَّا يَتَّخِذِ الْمُؤْمِنُونَ الْكَافِرِينَ أَوْلِيَاءَ مِن دُونِ الْمُؤْمِنِينَ ۖ وَمَن يَفْعَلْ ذَٰلِكَ فَلَيْسَ مِنَ اللَّهِ فِي شَيْءٍ إِلَّا أَن تَتَّقُوا مِنْهُمْ تُقَاةً ۗ وَيُحَذِّرُكُمُ اللَّهُ نَفْسَهُ ۗ وَإِلَى اللَّهِ الْمَصِيرُ
3|28|Believers are not to take disbelievers as an Authority/Ruler instead of believers. Whoever does that has nothing to do with God, unless it is to protect your own selves against them. God warns you to beware of Him. To God is the destiny.
The two words tattaqū (“you fear”) and tuqāt “in fear” are derived from the same root as taqiya.
40|28|A believing man from Pharaoh’s family, who had concealed his faith, said, “Are you going to kill a man for saying, `My Lord is God,’ and he has brought you clear proofs from your Lord? If he is a liar, his lying will rebound upon him; but if he is truthful, then some of what he promises you will befall you. God does not guide the extravagant imposter.
Here we learn that around Pharaoh there was a person who had hidden his faith, no doubt for his own protection. Pharaoh was advocating to kill Prophet Musa AS at this point simply for believing in God, so there is a genuine concern for one’s life and property. The believing person then tried to appeal to Pharaoh using a rational argument, rather than simply religious, and this is an important point. When discussing topics with others, whether they are oppressing you or not, we have to set the nature of discussion that is relevant to them.
I will find the hadiths about Abu Talib and believers of his time, being like people of the cave doing Taqiya.