Muhammad's wife Hafsa once caught him in her bed with another woman—his slave-girl, Mary the Copt. Seeking to avoid further conflict, Muhammad promised that he would stop having sex with Mary. Later, however, Muhammad received one of his infamous morally convenient revelations from Allah.
Qur'an 66:1-2—O Prophet! why do you forbid (yourself) that which Allah has made lawful for you; you seek to please your wives; and Allah is Forgiving, Merciful. Allah indeed has sanctioned for you the expiation of your oaths and Allah is your Protector, and He is the Knowing, the Wise.
Here's Tafsir Jalalayn commenting on this verse:
O Prophet! Why do you prohibit what God has made lawful for you, in terms of your Coptic handmaiden Māriya — when he lay with her in the house of Hafsa, who had been away, but who upon returning [and finding out] became upset by the fact that this had taken place in her own house and on her own bed — by saying, ‘She is unlawful for me!’, seeking, by making her unlawful [for you], to please your wives? And God is Forgiving, Merciful, having forgiven you this prohibition.
For further confirmation, we have the following hadith:
Sunan An-Nasa'i 3411—It was narrated from Anas, that the Messenger of Allah had a female slave with whom he had intercourse, but Aishah and Hafsah would not leave him alone until he said that she was forbidden for him. Then Allah, the Mighty and Sublime, revealed: "O Prophet! Why do you forbid (for yourself) that which Allah has allowed to you" [66:1] until the end of the verse.
Since the Qur'an is supposedly Allah's eternal Word, our Muslim friends expect us to believe that, from eternity past, Allah had nothing better to do than compose verses giving Muhammad the right to break his oath to his wives so that he could continue having sex with his slave-girl.
***UPDATE*** A Muslim just claimed in the comments section that this hadith doesn't exist. So here it is as it appears in the Darussalam edition: