Middle East

Abbasid Caliphate
In the age of the Abbasid Caliphate, some references and anecdotes to same-sex love affairs and social views on gender and sexuality can be found in literary texts such as recorded poems.
In Jawāmiʿ al-ladhdha, a 10th century erotic compendium, individual proponents discuss their sexual preferences in contributed poems. Female poets, describe tribadism as a form of sexual gratification without the concomitant loss of reputation or risk of pregnancy. Other poets such as Abu'l-'Anbas Saymari, who is said to have written a book about lesbians and passive sodomites that has not survived to this day, described same-sex intercourse between two women as compatible due to the similarity of both love bodies and the equality of their relationship to other women.
The categorisation of different sex acts in Arabic-Islamic culture, was named according to the act rather than a particular orientation. A possible distinction according to El-Rouayheb is that of the active and passive part during the sexual intercourse. Thus, the act of two women haven intercourse was known as saḥḥāqāt, derived from saḥq for rubbing - in theory regardless of the gender identity of the partner.
An example of described homosexuality between men are the two poets Abū Nuwās and al-Buturī known for their affection for slave boys (ghulām) or socially inferior boys. In one story, al-Buturī's is selling Nasīm, a slave boy, to the son of a vizier, only to regret it later and buy him back at great financial sacrifice.
Abū Nuwās explicitly describes his affection for young male lovers in his poems, often referring to socially subordinate boys such as Christian tavern boys, student from mosques, or apprentices in the bureaucracy.
Egypt
Ancient Egypt
A Ramesside period ostraca, depicting a pederastic couple (a boy and man) having sex together
The duo Khnumhotep and Niankhkhnum, manicurists in the Palace of King Niuserre during the Fifth Dynasty of Egyptian pharaohs, c. 2400 BCE, are speculated to have been gay based on a representation of them embracing nose-to-nose in their shared tomb, though critics say that they were likely brothers. King Neferkare and General Sasenet, a Middle Kingdom story, has an intriguing plot revolving around a king's clandestine gay affair with one of his generals. It may reference the actual Pharaoh Pepi II, but critics say that the story may have been written to tarnish what was considered to be a unloved monarch.
Coptic Egypt
The sixth- or seventh-century Ashmolean Parchment AN 1981.940 provides the only example in Coptic language of a love spell between men. This vellum leaf contains an incantation by a man named Apapolo, the son of Noah, to compel the presence and love of another man Phello, the son of Maure. Phello will be restless until he finds Apapolo and satisfies the latter's desire.
Medieval Egypt
Sunni Islam eventually supplanted Christianity as the dominant religion of Egypt in the centuries following the Muslim conquest of Egypt. The native Egyptian population was tolerant of homosexual behaviors, but Islamic religious authority was discouraging of homosexual behaviors and non-traditional gender roles. However, Islamic law tolerated a smaller subsection of homosexual behaviors of pederasty, as the attraction to feminine male youth was viewed as natural and compatible with traditional Muslim gender roles.
Early modern Egypt
The Siwa Oasis was of special interest to anthropologists and sociologists because of its historical acceptance of male homosexuality. Some argue the practice arose because from ancient times unmarried men and adolescent boys were required to live and work together outside the town of Shali, secluded for several years from any access to available women. In 1900, the German egyptologist George Steindorff reported that, "the feast of marrying a boy was celebrated with great pomp, and the money paid for a boy sometimes amounted to fifteen pound, while the money paid for a woman was a little over one pound." The archaeologist Count Byron de Prorok reported in 1937 that "an enthusiasm could not have been approached even in Sodom... Homosexuality was not merely rampant, it was raging...Every dancer had his boyfriend...[and] chiefs had harems of boys.
Walter Cline noted that, "all normal Siwan men and boys practice sodomy...the natives are not ashamed of this; they talk about it as openly as they talk about love of women, and many if not most of their fights arise from homosexual competition....Prominent men lend their sons to each other. All Siwans know the matings which have taken place among their sheiks and their sheiks' sons....Most of the boys used in sodomy are between twelve and eighteen years of age." In the late 1940s, a Siwan merchant told the visiting British novelist Robin Maugham that the Siwan men "will kill each other for boy. Never for a woman".
Assyria
The Middle Assyrian Law Codes (1075 BCE) state: If a man has intercourse with his brother-in-arms, they shall turn him into a eunuch. This is the earliest known law condemning the act of male-to-male intercourse in the military. Despite these laws, sex crimes were punished identically whether they were homosexual or heterosexual in the Assyrian society. Freely pictured art of anal intercourse, practiced as part of a religious ritual, dated from the third millennium BCE and onwards.
Furthermore, the article 'Homosexualität' in Reallexicon der Assyriologie states,
Homosexuality in itself is thus nowhere condemned as licentiousness, as immorality, as social disorder, or as transgressing any human or divine law. Anyone could practice it freely, just as anyone could visit a prostitute, provided it was done without violence and without compulsion, and preferably as far as taking the passive role was concerned, with specialists. That there was nothing religiously amiss with homosexual love between men is seen by the fact that they prayed for divine blessing on it. It seems clear that the Mesopotamians saw nothing wrong in homosexual acts between consenting adults.
Israel
The ancient Law of Moses (the Torah) forbids men from lying with men (i.e., from having intercourse) in Leviticus 18 and gives a story of attempted homosexual rape in Genesis 19, in the story of Sodom and Gomorrah, after which the cities were soon destroyed with "brimstone and fire, from the Lord" and the death penalty was prescribed to its inhabitants and to Lot's wife who was tuned into a pillar of salt because she turned back to watch the cities' destruction. In Deuteronomy 22:5, cross-dressing is condemned as "abominable".
Persia
In pre-modern Islam there was a "widespread conviction that beardless youths possessed a temptation to adult men as a whole, and not merely to a small minority of deviants."
Muslim—often Sufi—poets in medieval Arab lands and in Persia wrote odes to the beautiful wine boys who served them in the taverns. In many areas the practice survived into modern times, as documented by Richard Francis Burton, André Gide, and others. Homoerotic themes were present in poetry and other literature written by some Muslims from the medieval period onward and which celebrated love between men. In fact these were more common than expressions of attraction to women.
Turkey
The Ottoman Empire
In a world before sexual preferences defined identity, men who desired other men were not thought of as members of a biologically determined, distinctive subculture with a constant nature. Because men and women were not thought of as opposites, same-sex relationships were not considered to go against nature. (In fact, women were thought of as biologically imperfect men.)