The Declaration of Independence promised life, liberty, and the pursuit of happiness to Americans. Of course, not everybody enjoyed those rights at first. But eventually those ideas took root and led the abolition of slavery and later to civil rights and women’s rights. It took even longer for people to take seriously the idea of homosexual activity as a matter of personal freedom and to recognize gays and lesbians as a group deserving of rights.

It was the classical liberals, the ancestors of libertarians, who first came to that recognition. From Montesquieu and Adam Smith in the 18th century to the Nobel Prize–winning economist F.A. Hayek in 1960, it was libertarians who insisted that (in Hayek’s words) “private practice among adults, however abhorrent it may be to the majority, is not a proper subject for coercive action for a state whose object is to minimize coercion.”

Historians have often noted the general danger to minorities of a powerful and expansive government. In his book Christianity, Social Tolerance, and Homosexuality, the Yale historian John Boswell wrote that “gay people were actually safer under the [Roman] Republic, before the state had the authority or means to control aspects of the citizenry’s personal lives. Any government with the power, desire, and means to control such individual matters as religious belief may also regulate sexuality, and since gay people appear to be always a minority, the chance that their interests will carry great weight is relatively slight.” In Intimate Matters: A History of Sexuality in America, John D’Emilio and Estelle Freedman noted that a growing commitment to freedom in 18th‐​century America brought about “an overall decline in state regulation of morality and a shift in concerns from private to public moral transgressions.”

Despite the broad influence of liberalism in the world, governments have continued to meddle in sexuality. As recently as the 1960s, homosexual relations were illegal in almost all states, and 13 states still had such laws on the books until the Supreme Court struck them down in 2003. When these laws were vigorously enforced, they drove gay people underground and created much misery. Gays and lesbians could not be open about their lives. If they were, they risked being fired, being thrown out of their homes, and even being beaten or killed. Once gay people stood up for their rights, social attitudes began to change and governments backed away from enforcing the laws. However, until the court ruling, sodomy laws were still used, for instance, to deny gay parents custody of their children.

Today, Libertarians believe, as John Stuart Mill famously wrote, that “over himself, over his own body and mind, the individual is sovereign.” That applies to gay people and to everyone else. Thus Libertarians continue to oppose laws criminalizing any consensual sexual activity among adults, in the United States and elsewhere.

Many Libertarians argue for the complete privatization of marriage, making marriage a matter of individual contract and — for those who want it — a religious ceremony, thus removing any need for state recognition of marriages. As long as marriage is licensed by government, however, same‐​sex couples are entitled to equal legal rights. The same rule applies to other government programs, from tax laws to Social Security to adoption. Libertarians would like to get government out of most areas, but as long as government is involved, it must treat citizens equally. The Supreme Court may be about to agree.