Caution: Translations of Quran and Ḥadīth may lead to possible misapplications and misinterpretations. This site is intended for students of sacred knowledge that are proficient in comprehending classical Arabic and have a strong foundation in Islamic sciences. Also note that religious injunctions rely on several aspects beyond what one may glean through reading individual aḥādīth.
quran:4:16

And the two who commit it among you, dishonor them both. But if they repent and correct themselves, leave them alone. Indeed, Allah is ever Accepting of repentance and Merciful.  

And when two of you (read wa’lladhāni or wa’lladhānni) men, commit it, that is, a lewd act, adultery or homosexual intercourse, punish them both, with insults and beatings with sandals; but if they repent, of this ˹lewd act˺, and make amends, through ˹good˺ action, then leave them be, and do not harm them. God ever turns ˹relenting˺, to those who repent, and is Merciful, to them. This ˹verse˺ is abrogated by the prescribed punishment if adultery is meant ˹by the lewd act˺, and similarly if homosexual intercourse is meant, according to al-Shāfi‘ī; but according to him, the person who is the object of the ˹penetrative˺ act is not stoned, even if he be married; rather, he is flogged and banished. Judging by the dual person pronoun, it seems more obvious that homosexual fornication is meant ˹by this verse˺, even though the former ˹sc. alShāfi‘ī˺ was of the opinion that it referred to an adulterer and an adulteress; but this ˹opinion of his˺ may be countered by the fact that ˹the reference to˺ the two ˹men˺ becomes clear on account of the particle min being attached to a masculine pronoun ˹minkum, ‘of you’˺, and by the fact that they suffer the same punishment, ˹both effect the action of˺ repentance and ˹are both granted˺ that they be left alone ˹thereafter˺, ˹all of˺ which applies specifically to men, given that for women detention is stipulated, as was stated before.
القرآن:٤:١٦

وَاللَّذَانِ يَأْتِيَانِهَا مِنْكُمْ فَآذُوهُمَا ۖ فَإِنْ تَابَا وَأَصْلَحَا فَأَعْرِضُوا عَنْهُمَا ۗ إِنَّ اللَّهَ كَانَ تَوَّابًا رَحِيمًا  

{وَاًلَّلذّانِ} بتخفيف النون وتشديدها {يأتيانها} أي الفاحشة الزنا أو اللواط {منكم} أي الرجال {فآذوهما} بالسب والضرب بالنعال {فإن تابا} منها {وأصلحا} العمل {فأعرضوا عنهما} ولا تؤذوهما {إن الله كان توَّابا} على من تاب {رحيما} به وهذا منسوخ بالحد إن أريد بها الزنا وكذا إن أريد بها اللواط عن الشافعي لكن المفعول به لا يرجم عنده وإن كان محصنا بل يجلد ويغرب وإرادةُ اللواط أظهر بدليل تثنية الضمير والأول أراد الزاني والزانية ويرده تبيينهما بمن المتصلة بضمير الرجال واشتراكهما في الأذى والتوبة والإعراض وهو مخصوص بالرجال لما تقدم في النساء من الحبس.