While it may be acceptable for some or a matter of personal choice for others, anal sex is a forbidden act and a major sin in Islam. Muslims have to observe the teachings of Islam in all walks of life, including the intimate relations between a husband and wife.
Dr. Salah Al-Sawy, secretary-general of the Assembly of Muslim Jurists in America (AMJA), stated,
Sexual intercourse with one’s wife by way of her back passage is a major sin. Almighty Allah says,
(Your wives are as a tilth unto you, so approach your tilth as you will, but do some good act for yourselves beforehand, and fear Allah, and know that you are to meet Him (in the hereafter), and give glad tidings to the believers.)(Al-Baqarah 2:223)
here, Almighty Allah draws a metaphor of the female front passage (which is the place of planting offspring) as the land through which seeds are cast into the womb, which receives the sperm in a process leading to reproduction.
that is what is planted when one approaches one’s wife by way of this part. Allah’s words (as you will) mean that a husband may approach his wife from any direction he likes: from the front or from the back — whether his wife is kneeling, lying down, or reclining, so long as the intercourse is by way of the front passage, where the planting and reproduction would take place.
The Prophet Muhammad (peace and blessings be upon him) said, “Whoever approaches [in sex] a menstruating woman or a woman in her anus … has disbelieved in what came down upon Muhammad (peace and blessings be upon him)” (At-Tirmidhi, Ibn Majah, and Ahmad).
The Prophet also said to `Umar ibn Al-Khattab, “[You are free to] go from the front and the back, but avoid the anus and menses” (At–Tirmidhi and Ahmad).
As for passing the penis across the buttocks or placing it between the buttocks or the thighs, this is permissible. This is because the basic ruling with regard to one’s enjoyment with his or her spouse is that there is permissibility. This ruling has no exceptions other than the menses and sexual intercourse by way of the back passage, as the Prophet said.