Is the Thigh Part of the `Awrah?
Question

Can we quote as evidence for it being permissible to uncover the thigh the Hadith which says that the Prophet (blessings and peace of Allah be upon him) uncovered his thigh in front of Abu Bakr and `Umar; and the Hadith narrated by Al-Bukhari in which it says: My knee was touching the thigh of the Prophet (blessings and peace of Allah be upon him), then he rolled up his Izar (waist wrapper) and uncovered his thigh” and the report narrated by Al-Haythami from Abu Sa`id in which it says: “He let his legs dangle in the well and uncovered his thighs”?
Praise be to Allah.Scholarly Difference on Thighs as `Awrah
The scholars (may Allah have mercy on him) differed concerning the thigh of a man and whether it is included within the limits of the `Awrah or not . There are two views:

The first view, which is the view of the majority of scholars, is that the thigh is `Awrah.
The second view, which was narrated in the Madhhab of Ahmad, and was the view favoured by Shaykh Ibn `Uthaymin (may Allah have mercy on him), is that the thigh is not `Awrah.

It says in Al-Mawsu`ah Al-Fiqhiyyah (32/57):
The jurists differed as to whether a man’s thigh is to be regarded as `Awrah. The majority of jurists are of the view that a man’s thigh is `Awrah and it must be covered.
A number of scholars – including `Ata’, Dawud, Muhammad ibn Jarir, and  Abu Sa`id Al-Istakhri among the Shafi`is, and it is also narrated from Ahmad – are of the view that the thigh is not `Awrah. (End quote)
Ibn Battal (may Allah have mercy on him) said:
Those who say that the thigh is not `Awrah quoted as evidence the Hadith of Anas, and the Hadith of Zayd ibn Thabit,  because if it was `Awrah , it would have been obligatory to cover it and the Prophet (blessings and peace of Allah be upon him) would not have uncovered it on the day of Khaybar, and he would not have left it uncovered in the presence of Abu Bakr and `Umar.
So what is meant by saying “the thigh is `Awrah” is because it is near the front and back passage. They unanimously agreed that if a person prays with his front and back passages uncovered, he has to repeat the prayer, but they differed concerning one who prays with his thigh uncovered. This indicates that the ruling on the thigh is different from the ruling on the front and back passages.
If someone were to ask: why did the Prophet (blessings and peace of Allah be upon him) cover his knee when `Uthman ibn `Affan entered upon him? The answer is: The Prophet (blessings and peace of Allah be upon him) explained the reason for that when he said: “Should I not feel shy before one before whom the angels of heaven feel shy?” (End quote from Sharh Sahih Al-Bukhari by Ibn Battal, 2/33-34)
Ibn Hajar (may Allah have mercy on him) said: One of the things that they – i.e., those who say that the thigh is not `Awrah– quoted as evidence was the words of Anas (may Allah be pleased with him) in this Hadith: “My knee was touching the thigh of the Prophet of Allah (blessings and peace of Allah be upon him)”, because the apparent meaning would suggest that this touching occurred without a barrier, and touching the `Awrah without a barrier is not permissible. According to the report of Muslim and those who followed him: the Izar did not uncover it as a result of a deliberate action on the part of the Prophet (blessings and peace of Allah be upon him), but we may conclude that the thigh is not `Awrah, on the basis that he left it like that, because even though it is possible that this may happen unintentionally, if it was `Awrah he would not have left it like that, because he was infallible (blessings and peace of Allah be upon him). (End quote from Fat-h Al-Bari, 1/481)
The scholars of the Standing Committee were asked: Is the thigh `Awrah?
They replied:
The majority of jurists are of the view that a man’s thigh is `Awrah, and they quoted as evidence for that some Hadiths, none of which are unproblematic, either because the chain of narration is not complete, or some of the narrators are inauthentic, but they support one another, so as a whole they may be taken as evidence concerning this matter.
One of these Hadiths is the Hadith that was narrated by Abu Dawud and Ibn Majah from `Ali (may Allah be pleased with him) who said: The Messenger of Allah (blessings and peace of Allah be upon him) said:  “Do not uncover your thigh or look at the thigh of another man, living or dead.” They also quoted the report narrated by Ahmad and by Al-Bukhari in his Tarikh, from Muhammad ibn Jahsh (may Allah be pleased with him) who said: The Messenger of Allah (blessings and peace of Allah be upon him) passed by Ma`mar ibn `Abdullah, whose thighs were uncovered, and he said: “O Ma`mar, cover your thighs, for the thighs are `Awrah.”
Another of these reports is that which was narrated by Malik in Al-Muwatta’, and by Ahmad, Abu Dawood and at-Tirmidhi, from Jarhad Al-Aslami (may Allah be pleased with him), who said: The Messenger of Allah (blessings and peace of Allah be upon him) passed by when I was wearing a cloak and had uncovered my thigh. He said: “Cover your thigh, for the thigh is `Awrah.” It was classed as sound by At-Tirmidhi.
A number of scholars were of the view that a man’s thigh is not `Awrah, and they quoted as evidence for that the report narrated by Anas (may Allah be pleased with him), according to which the Prophet (blessings and peace of Allah be upon him) rolled up the Izar from his thigh to the extent that I could see the whiteness of his thigh. (Narrated by Ahmad and Al-Bukhari). Al-Bukhari said: The Hadith of Anas is stronger in terms of chain of narration , and the Hadith of Jarhad is more prudent.
The view of the majority is more prudent, because of what Al-Bukhari mentioned, and because the first Hadith addresses this matter in particular, whereas the Hadith of Anas (may Allah be pleased with him) may be interpreted in different ways. (End quote from Fatawa Al-Lajnah Ad-Da’imah, vol. 1, 6/165-166)
To sum up, whether the thigh is part of a man’s `Awrah is a matter concerning which there is a difference of scholarly opinion, but to be on the safe side and as a precaution to protect his religious commitment, morals and dignity, the Muslim should cover his thigh, especially nowadays when temptation and turmoil are so widespread, including infatuation with appearances and images.
Situational Exceptions for Covering the Thighs
Some of those who say that the thigh is not `Awrah make an exception in two cases:

When praying

It is not permissible to uncover the thigh when praying, because that is contrary to the command to wear one’s adornment at the time of every prayer.
Shaykh Al-Islam (may Allah have mercy on him) said:
So if we follow one of the two views, which is one of the two reports narrated from Ahmad, that the `Awrah is the front and back passages, and that the thigh is not `Awrah, this has to do with a man looking at it, but this is not applicable in the case of prayer and Tawaf. It is not permissible for a man to pray with his thighs uncovered, regardless of whether we say that they are `Awrah or not, and it is not permissible to circumambulate the Ka`bah (Tawaf) naked. (End quote from Majmu` Al-Fatawa, 22/116)

At times of temptation

Such as when the one who uncovers his thighs is a source of temptation, as in the case of young men, for example.
Shaykh Ibn `Uthaymin (may Allah have mercy on him) said: What appears to me to be the correct view is that the thigh is not `Awrah, except in cases where there is the fear of temptation if it is uncovered, in which case it is obligatory to cover it, such as the thighs of a young man. (End quote from Majmu` Fatawa Ibn `Uthaymin, 12/265)
For further insights, explore these answers:
Men’s `Awrah and wearing pants with shirt tucked in
`Awrah for Men: Why Is the Man’s Chest Not Included?
What is the ruling on trousers that show the shape of a man’s `Awrah?
And Allah knows best.