Srimad Bhagavatam Canto 09, Chapter 18, Text 32

SB 9.18.32

raja-putryarthito ’patye
 dharmam caveksya dharmavit
smarañ chukra-vacah kale
 distam evabhyapadyata
 
Translation by His Divine Grace A. C. Bhaktivedanta Swami Srila Prabhupada: 
 
When Princess Sarmistha begged King Yayati for a son, the King was certainly aware of the principles of religion, and therefore he agreed to fulfill her desire. Although he remembered the warning of Sukracarya, he thought of this union as the desire of the Supreme, and thus he had sex with Sarmistha.
 
Purport by His Divine Grace A. C. Bhaktivedanta Swami Srila Prabhupada: 
 
King Yayati was completely aware of the duty of a ksatriya. When a ksatriya is approached by a woman, he cannot deny her. This is a religious principle. Consequently, when Dharmaraja, Yudhisthira, saw Arjuna unhappy after Arjuna returned from Dvaraka, he asked whether Arjuna had refused a woman who had begged for a son. Although Maharaja Yayati remembered Sukracarya’s warning, he could not refuse Sarmistha. He thought it wise to give her a son, and thus he had sexual intercourse with her after her menstrual period. This kind of lust is not against religious principles. As stated in Bhagavad-gita (7.11), dharmaviruddho bhutesu kamo ’smi: sex life not contrary to the principles of religion is sanctioned by Krsna. Because Sarmistha, the daughter of a king, had begged Yayati for a son, their combination was not lust but an act of religion.
Srimad Bhagavatam Canto 09, Chapter 18, Text 31
Srimad Bhagavatam Canto 09, Chapter 18, Text 33