Instead of wondering why same-sex behavior had independently evolved in so many species, Ms. Monk and her colleagues suggest that it may have been present in the oldest parts of the animal family tree. The earliest sexually reproducing animals may have mated with any other individual they came across, regardless of sex. Such reproductive strategies are still practiced today by hermaphroditic species, like snails, and species that don’t appear to differentiate, like sea urchins.

Over time, Ms. Monk said, sexual signals evolved — different sizes, colors, anatomical features and behaviors — allowing different sexes to more accurately target each other for reproduction. But same-sex behavior continued in some organisms, leading to diverse sexual behaviors and strategies across the animal kingdom. And while same-sex behavior may grant some evolutionary benefits, an ancient origin would mean those benefits weren’t required for it to exist.

But how has same-sex behavior stuck around? The answer may be that such behaviors aren’t as evolutionarily costly as assumed. Traditionally, Ms. Monk said, any mating behavior that doesn’t produce young is seen as a waste. But animal behavior often doesn’t fit neatly into an economic accounting of costs and benefits.

Mating attempts between different sexes don’t always efficiently lead to offspring either, Dr. Kamath said — mating attempts can be rebuffed, conception may not occur and clutches or young may not survive. These are normal hiccups in population-level reproduction, and the team predicts that the costs of same-sex behavior aren’t likely to be any greater.

“I don’t think it’s unreasonable to assume that at some early stage of animal evolution mating was more indiscriminate and that this is part of the evolutionary heritage of higher animals,” Dr. Vasey said of the study. “Occasional same-sex sexual behavior is not particularly difficult to accommodate within an evolutionary framework when such behavior is performed within the larger context of different-sex sexual behavior.”

An issue with past research in the field, Dr. Lambert said, is that unexamined cultural projections — largely by the white heterosexual men who have dominated the field — resulted in many researchers failing to accurately document what they were seeing.