Every Muslim should try his best to avoid forms of sexual pleasure that are prohibited such as having anal sex or sexual intercourse during menses or else during the daytime of Ramadan. Almighty Allah says in the Qur’an: “Your wives are a tilth for you, so go to your tilth (have sexual relations with your wives in any manner as long as it is in the vagina and not in the anus), when or how you will, and send (good deeds, or ask Allah to bestow upon you pious offspring) for your own selves beforehand. And fear Allah, and know that you are to meet Him (in the Hereafter), and give good tidings to the believers (O Muhammad).” (Al-Baqarah: 223)
In the foregoing verse the word harth (tilth) indicates that only vaginal sex is permissible in Islam, because it is from this place children are produced. The semen lodged in the womb from which offspring comes is likened to the seeds that are planted in the ground, bringing vegetation. Both of them are substances from which something else is produced.
All Muslim jurists agree that anal sex is haram (prohibited), based on the hadith of the Prophet (peace and blessings be upon him): “Do not have anal sex with women.” (Reported by Ahmad, At-Tirmidhi, An-Nasa’i, and Ibn Majah.)
Khuzaymah Ibn Thabit (may Allah be pleased with him) also reported that the Messenger of Allah (peace and blessings be upon him) said: “Allah is not too shy to tell you the truth: Do not have sex with your wives in the anus.” (Reported by Ahmad, 5/213.)
Ibn `Abbas (may Allah be pleased with him) narrated: “The Messenger of Allah (peace and blessings be upon him) said: “Allah will not look at a man who has anal sex with his wife.” (Reported by Ibn Abi Shaybah, 3/529, and At-Tirmidhi classified it as an authentic hadith, 1165)
Further, it is reported that the Prophet (peace and blessing be upon him) referred to such an act as “minor sodomy”. (Reported by Ahmad and An-Nasa’i)
However, it is allowed to caress the wife and stimulate her around the anus, without having sex in this area. It is reported that `Umar Ibn Al-Khattab (may Allah be pleased with him) came one day to the Prophet and said, “O Messenger of Allah, I am ruined!” “What has ruined you?” asked the Prophet. He replied, “Last night I turned my wife over,” meaning that he had had vaginal intercourse with her from the back. The Prophet (peace and blessings be upon him) did not say anything to him until the verse cited above was revealed. Then he told him, “[Make love with your wife] from the front or the back but avoid the anus and intercourse during menstruation.” (Reported by Ahmad and At-Tirmidhi)
Based on this, we can conclude that there is nothing wrong to caress the wife around the anus and to touch the anus with one’s hands as a form of sexual pleasure.