Uwaymir bin Ashqar al-Ajlani came to Asim bin Adi al-Ansari (may Allah be pleased with him) and said to him: O Asim, what is your view about a man who finds another man with his wife: if he kills him, will you kill him in retaliation, or what should he do? O Asim, ask the Messenger of Allah (peace and blessings be upon him) about it for me. So Asim asked the Messenger of Allah (peace and blessings be upon him) about it, and he (peace and blessings be upon him) disliked such questions and found fault with them, until what he had asked the Messenger of Allah (peace and blessings be upon him) weighed heavily on Asim. When Asim returned to his family, Uwaymir came to him and said: O Asim, what did the Messenger of Allah (peace and blessings be upon him) say to you? Asim said to Uwaymir: You have never brought me anything good; the Messenger of Allah (peace and blessings be upon him) disliked the question I asked him (peace and blessings be upon him). Uwaymir said: By Allah, I will not stop until I ask him (peace and blessings be upon him) myself. So Uwaymir went forward until he came to the Messenger of Allah (peace and blessings be upon him), while he (peace and blessings be upon him) was sitting among the people, and said: O Messenger of Allah, what is your view about a man who finds another man with his wife: if he kills him, will you kill him in retaliation, or what should he do? The Messenger of Allah (peace and blessings be upon him) said: "A verse has been revealed concerning you and your companion; go and bring her." Sahl (may Allah be pleased with him) says: So the two of them performed li'an, and I was with the people in the presence of the Messenger of Allah (peace and blessings be upon him). When they had finished, Uwaymir said: If I keep her, then I will have lied against her. So Uwaymir divorced her three times before the Messenger of Allah (peace and blessings be upon him) commanded him. Ibn Shihab says: "Then this became the practice for the two who perform li'an."
Hadith Referenceالمعجم الكبير للطبراني / باب السين / 5654