Sahih al-Bukhari, Hadith 695

Narrated 'Ubaid-Ullah bin Adi bin Khiyar: I went to 'Uthman bin Affan while he was besieged, and said to him, "You are the chief of all Muslims in general and you see what has befallen you. We are led in the Salat (prayer) by a leader of Al-Fitan (trials and afflictions etc.) and we are afraid of being sinful in following him." 'Uthman said. "As-Salat (the prayers) is the best of all deeds so when the people do good deeds do the same with them and when they do bad deeds, avoid those bad deeds." Az-Zuhri said, "In our opinion one should not offer Salat behind an effeminate person unless there is no alternative."

قَالَ أَبُو عَبْدِ اللَّهِ وَقَالَ لَنَا مُحَمَّدُ بْنُ يُوسُفَ حَدَّثَنَا الأَوْزَاعِيُّ، حَدَّثَنَا الزُّهْرِيُّ، عَنْ حُمَيْدِ بْنِ عَبْدِ الرَّحْمَنِ، عَنْ عُبَيْدِ اللَّهِ بْنِ عَدِيِّ بْنِ خِيَارٍ، أَنَّهُ دَخَلَ عَلَى عُثْمَانَ بْنِ عَفَّانَ ـ رضى الله عنه ـ وَهْوَ مَحْصُورٌ فَقَالَ إِنَّكَ إِمَامُ عَامَّةٍ، وَنَزَلَ بِكَ مَا تَرَى وَيُصَلِّي لَنَا إِمَامُ فِتْنَةٍ وَنَتَحَرَّجُ‏.‏ فَقَالَ الصَّلاَةُ أَحْسَنُ مَا يَعْمَلُ النَّاسُ، فَإِذَا أَحْسَنَ النَّاسُ فَأَحْسِنْ مَعَهُمْ، وَإِذَا أَسَاءُوا فَاجْتَنِبْ إِسَاءَتَهُمْ‏.‏ وَقَالَ الزُّبَيْدِيُّ قَالَ الزُّهْرِيُّ لاَ نَرَى أَنْ يُصَلَّى خَلْفَ الْمُخَنَّثِ إِلاَّ مِنْ ضَرُورَةٍ لاَ بُدَّ مِنْهَا‏.‏

sunnah.com