Same-sex sexual activity is illegal in Pakistan.

The Pakistan Penal Code (originally developed as the Indian Penal Code under the British Raj), criminalises sodomy with possible penalties of prison sentences from two years to a life sentence and fines. Despite its illegality, homosexual acts are only occasionally prosecuted by authorities, but it is sometimes used to threaten and harass homosexuals under threat of prosecution. Other morality and public order provisions in the Penal Code are used to target LGBTQ Pakistanis as well. Another greater problem can be vigilante policing and killings by Islamist and terrorist groups. Police may also act illegally and arrest LGBTQ individuals despite the law stating otherwise.

A majority of the people living in Pakistan believe that homosexuality is a sin in Islam. Nearly all religious leaders agree that the story of the prophet Lut shows that Islam does not approve of homosexuality. Multiple clerics call for punishment of homosexuals based on the Sharia. Nevertheless, the LGBTQ community is still able to socialise, organise, date, and even—in rare cases—live together as couples, if done mostly in secret.

Implementation of law Section 377 of the Pakistan Penal Code (PPC) defines 'carnal intercourse against the order of nature', as punishable by a fine and/or imprisonment for a period of 2 years to life. This rarely lead to convictions or prosecutions in the judicial courts, but have sometimes been used by police as a means to extract bribes or sexual favours under threat of prosecution, particularly against homosexual men and transgender women, who may also be subject to harassment, humiliation, and violence by the police, including sexual violence. The UN noted that there had been arrests of homosexuals within the past three years in 2018, 2019 and 2022.

The Offence of Zina in the Enforcement Of Hudood Ordinance criminalizes any form of penetration in a sexual act outside of marriage. Sharia law carries heavy penalties for homosexuality from imprisonment for 2–10 years or for life, or of 100 lashes or stoning to death if the person is married. The IRB noted that due to the proof-of-evidence requirements, convictions under Sharia Law are rare, but that the fear remained very high. The IGLA noted that though the death penalty remains optional, it has no evidence that the death penalty was ever implemented.

2018 Transgender Persons (Protection of Rights) Act (TPPR Act) provides transgender people with recognition. However numerous sourced noted that transgender people continued to be illegally arrested and those who have been legally identified as a certain gender are often treated as the opposing gender.

Due to a lack of anti-discrimination protections and widespread homophobia among authorities, LGBTQ are generally reluctant to be open about their sexuality as they may face abuses such as forced marriage, honor killings, humiliation, societal discrimination and harassment. They worry that if their sexuality is known, they may be exposed to violence or blackmail.

A person living openly as LGBTQ is likely to be at risk of treatment from non-state actors such as Islamist organizations and terrorist groups.

Legality of same-sex sexual activity

Pakistani law is a mixture of both British law and Islamic law. The section of the Penal Code criminalising consensual same-sex relations was inherited from the colonial rule of the British Raj; it was enacted on 6 October 1860 and went into force on 1 January 1862. Written by Lord Macaulay, the then-named Indian Penal Code 1860, made male same-sex sexual acts illegal under the British law of "Unnatural Offences". After Pakistan gained independence in 1947, the Parliament retained the Penal Code, merely changing the title to Pakistan Penal Code (Act XLV of 1860). Within the Penal Code, Article 377 ("Unnatural Offences") states: "Whoever voluntarily has carnal intercourse against the order of nature with any man, woman or animal, shall be punished with imprisonment ... for a term which shall not be less than two years nor more than ten years, and shall also be liable to fine".

It is likely that the region that encompasses Pakistan had been influenced by homophobic values at a much earlier period than other Asian regions such as the Indosphere and Sinosphere. Evidence from literary works and artworks relating to Zoroastrianism, Buddhism and Islam suggest that non-heterosexual sex was looked down upon or forbidden since at least 250 B.C. Historically around 250 BC, during the Parthian Empire, the Zoroastrian text Vendidad was written. It contains provisions that are part of sexual code promoting procreative sexuality that is interpreted to prohibit same-sex intercourse as sinful. Ancient commentary on this passage suggests that those engaging in sodomy could be killed without permission from a high priest.

Implementation of the laws against homosexuality are generally unenforced but do still happen. In 2014 a Pakistani man sought asylum in Australia for fear of being jailed for homosexuality in Pakistan. In early 2023 numerous people were arrested for engaging in homosexual pornography. A greater problem can be vigilante policing and killings by Islamist and terrorist groups.

As part of the Islamization in Pakistan under Muhammad Zia-ul-Haq, the Hudud Ordinances were enacted in 1979, stipulating severe punishments for adultery, fornication, consuming alcohol and sodomy. According to the United States State Department's 2021 annual report on human rights practices in Pakistan, the Hudood Ordinances have not been enforced "since the 1985 lifting of martial law", and there are no known cases of it being applied to same-sex sexual conduct. No known executions for homosexual activity have occurred.

Pakistan Penal Code of 1860 Relevant sections of the penal code are as follows: Article 141 – An assembly of five or more persons is designated an "unlawful assembly" if the common object of the persons composing that assembly is... to commit any mischief or criminal trespass, or other offence. Article 153 – Whoever by words, either spoken or written, or by signs, or by visible representations, or otherwise, induce or attempts to induce any student, or any class of students, or any institution interested in or connected with students, to take part in any political activity which disturbs or undermines, or is likely disturb or undermine, the public order shall be punished with imprisonment which may extend to two years or – with fine or with both. Article 268 – A person is guilty of a public nuisance who does any act or is guilty of an illegal omission which causes any common injury, danger or annoyance to the public or to the people in general who dwell or occupy property in the vicinity, or which must necessarily cause injury, obstruction, danger or annoyance to persons who may have occasion to use any public right. Article 269 – Whoever unlawfully or negligently does any act which is, and which he knows or has reason to believe to be, likely to spread the infection of any disease dangerous to life, shall be punished with imprisonment of either description for a term which may extend to six months, or with fine, or with both. Article 270 – Whoever malignantly does any act which is, and which he knows or has reason to believe to be, likely to spread the infection of any disease dangerous to life, shall be punished with imprisonment of either description for a term which may extend to two years, or with fine, or with both. Article 290 – Whoever commits a public nuisance in any case not otherwise punishable by this Code, shall be punished with fine which may extend to six hundred rupees. Article 292 – Prohibits the sale, distribution, exhibition, ownership or importation of any, "obscene" books, pamphlets, or other literature or images. Article 294 – Prohibits any "obscene" public acts, songs, music or poems. Article 371A – Whoever sells, lets to hire, or otherwise disposes of any person with intent that such a person shall at any time be employed or used for the purpose of prostitution or illicit intercourse with any person or for any unlawful and immoral purpose, or knowing it to be likely that such person shall at any time be employed or used for any such purpose, shall be punished with imprisonment which may extend to twenty-five years, and shall also be liable to fine. Article 371B – When a female is sold, let for hire, or otherwise disposed of to a prostitute or to any person who keeps or manages a brothel, the person so disposing of such female shall, until the contrary is proved, be presumed to have disposed of her with the intent that she shall be used for the purpose of prostitution. For the purposes of this section and section 371B, "illicit intercourse" means sexual intercourse between persons not united by marriage. Article 377 – Whoever voluntarily has carnal intercourse against the order of nature with any man, woman or animal, shall be punished with imprisonment for life, or with imprisonment of either description for a term which shall not be less than two years nor more than ten years, and shall also be liable to fine. Penetration is sufficient to constitute the carnal intercourse necessary to the offence described in this section. Article 496 – Whoever, dishonestly or with a fraudulent intention, goes through the ceremony of being married, knowing that he is not thereby lawfully married, shall be punished with imprisonment of either description for a term which may extend to seven years, and shall be liable to fine.

Constitutional rights The Pakistani Constitution does not explicitly make mention of sexual orientation or gender identity. It does contain certain provisions that may impact the constitutional rights of LGBTQ Pakistani citizens.

Part II 37. The government pledges to promote Islamic values among its Muslim citizens, to protect marriage and the family and to oppose obscenity. Part IX 227. Islam is the official state religion, and all laws, rules, regulations and other such legislation must be compatible with Islam, as defined by a government appointed Islamic council.

Discrimination protections No civil rights legislation exists to prohibit public or private sector discrimination on the basis of sexual orientation. However, since 2018, discrimination on the basis of gender identity is prohibited in a wide range of areas, including employment, education, health care, access to goods and services, housing and public office. The International Commission of Jurists summarises the coverage of the act:

Sociologists Stephen O. Murray and Badruddin Khan have written that the penal laws themselves are rarely enforced directly, but are used by the police and other private citizens as a form of blackmail.

In March 2012, at the Human Rights Council, Hina Jilani, who was then also Chair of the Human Rights Commission of Pakistan and former Special Representative of the Secretary-General, said,it was very important to emphasise that a serious obstacle was the persistent denial of protection for people from violence on the basis of sexual orientation and gender identity. That denial and rejection were not prudent for any Government that claimed the commitment to the promotion and protection of human rights. It was not convincing when culture and religion were used as a shield and an excuse for failure to protect. There was no notion of responsibility that allowed duty bearers to selectively hold out on protection.

Gender identity and expression