Wikipedia:Amnon and Tamar story

The story of Amnon and Tamar is a biblical story (in the Books of Samuel, chapter thirteen, verses 1-7) that tells the story of Amnon, the son of David and Ahinoam the Jezreelite, who raped his sister Tamar the daughter of David and Maacah daughter of Ptolemy king of Geshur.

The story opens with Tamar and presents her as Absalom's sister and a beautiful woman. Amnon, the son of King David, fell in love with her and sought an excuse to be with her in units. On the advice of Yonadav Ben Shema, his cousin, he pretended to be ill, and asked his sister Tamar to come to his room and make him pancakes (Levivot). When Tamar came to his room and prepared the Levivot before him, Amnon refused to eat until all the king's servants present in the room had left, and he would eat from her hands.

After they left, Amnon asked Tamar to come into his room and feed him there. When she entered his room, he tried to seduce her to sleep with him, and when she refused, he raped her. After the rape, Amnon demanded that Tamar leave his room, despite her request that she be married so that her name would not be stained, and as the Torah commands. When she refused to leave, he ordered one of his servants to take her out of his room and lock the door lest she try to enter.

Tamar, who was wearing a striped shirt, tore her shirt, put ashes on her head (signs of mourning), and cried out for the injustice done to her. When Absalom, her brother from father and mother, heard this, he ordered her to remain silent and not claim her insult, on the pretext that Amnon was her brother, but in his heart he plotted to avenge Amnon, and indeed killed him later.

Throughout the ages the story has received many interpretations that have attempted to address its halakhic and moral problems. Some chose to clear Amnon of guilt (for example in the argument that this act was one of the punishments in which David was punished). Others emphasized the role of Amnon's friend in the act (claiming that he advised Amnon on how to bring Tamar to him, and that he may have only intended to create an intimate situation that would allow a marriage proposal). Others tried to clear Amnon of incest and demanded that Tamar be born before her mother converted, and therefore she is not Jewish, and is not considered Amnon's sister. Others blamed Tamar for Amnon's anger at her. A minority of the old commentaries deal with Tamar and her attempt to protect herself from rape.

background
The story of Amnon and Tamar is a sequel to the deed of David and Batsheva, and is presented in the Bible as the first punishment David received for his sin. According to the deed of David and Batsheva, King David summoned Batsheva, the wife of Uriah the Hittite, to him and slept with her. When he learned that Batsheva was pregnant, he called Uriah from the war that was taking place at that time against the Ammonites, in order to obscure what was happening. But Uriah refrained from obeying King David's order to return to his house, and David ordered Army Minister Yoav to take care of Uriah's death in the war by placing him at the forefront of the battle, on the pretext that he had rebelled against the king in his refusal and harsh words towards the king. Yoav obeyed the order, and Uriah died in the war.

The prophet "Natan" compared to David what he did in the parable of the "poor sheep" to explain to him his sin. David immediately confessed his sin and accepted the heavenly punishment he had imposed on himself in the judgment he gave in relation to the story of the imaginary Hersh sheep: "He must pay for that lamb four times over, because he did such a thing and had no pity" (Samuel 2, chapter 12, verse 6). The four payments were:
 * 1) The death of the son who gave birth to a seven-year-old girl from the pregnancy is measured.
 * 2) Tamar rape by Amnon
 * 3) Amnon's death, which was a direct result of the rape.
 * 4) Death of Avshalom

Implications of the story on Jewish law
The Talmud claims that after the rape of Tamar, David and his high court extended the Yichud halakha that prohibition to unmarried girls as well. Later, in the times of Shammai and Hillel the Elder, the prohibition was extended to include a non-Jewish woman. These rules are discussed in the Talmud.

And so it was indeed ruled according to Halacha in Shulchan Aruch:"And even though she is not a relative, he must not be alone with her."