During the winter mating season, competition is fierce for access to female Japanese macaques. But it's not for the reason you might think. Males don't just have to compete with other males for access to females: they have to compete with females too.

That's because in some populations, homosexual behaviour among females is not only common, it's the norm. One female will mount another, then stimulate her genitals by rubbing them against the other female. Some hold onto each other with their limbs using a "double foot clasp mount", while others sit on top of their mates in a sort of jockey-style position, says Paul Vasey of the University of Lethbridge in Alberta, Canada, who has been studying these macaques for over 20 years.

To our eyes these encounters look startlingly intimate. The females stare into each other's eyes while mating, which macaques hardly ever do outside of sexual contexts. The pairings can even last a whole week, mounting hundreds of times. When they're not mating, the females stay close together to sleep and groom, and defend each other from possible rivals.

That many humans are homosexual is well known but we also know the behaviour is extremely common across the animal kingdom, from insects to mammals. So what's really going on? Can these animals actually be called homosexual?

Animals have been observed engaging in same-sex matings for decades. But for most of that time, the documented cases were largely seen as anomalies or curiosities.

The turning point was Bruce Bagemihl's 1999 book Biological Exuberance, which outlined so many examples, from so many different species, that the topic moved to centre stage. Since then, scientists have studied these behaviours systematically.

On the face of it, homosexual behaviour by animals looks like a really bad idea

Despite Bagemihl's roster of examples, homosexual behaviour still seems to be a rarity. We have probably missed some examples, as in many species males and females look pretty much alike. But while hundreds of species have been documented doing it on isolated occasions, only a handful have made it a habitual part of their lives, says Vasey.

To many, that isn't surprising. On the face of it, homosexual behaviour by animals looks like a really bad idea. Darwin's theory of evolution by natural selection implies that genes have to get themselves passed on to the next generation, or they will die out. Any genes that make an animal more likely to engage in same-sex matings would be less likely to get passed on than genes pushing for heterosexual pairings, so homosexuality ought to quickly die out.

But that evidently isn't what's happening. For some animals, homosexual behaviour isn't an occasional event – which we might put down to simple mistakes – but a regular thing.

Take the macaques. When Vasey first observed the females mounting each other, he was "blown away" by how often they did it.

The females were simply seeking sexual pleasure

"So many females of the group are engaging in this behaviour and there are males sitting around twiddling their thumbs," he says. "There's got to be a reason for this. There is no way the behaviour can be evolutionarily irrelevant."

Vasey's team has found that females use a greater variety of positions and movements than males do. In a 2006 study, they proposed that the females were simply seeking sexual pleasure, and were using different movements to maximise the genital sensations. "She can do so in a homosexual context just as easily as in a heterosexual context, so the behaviour spills over," says Vasey.

But for all the homosexual pairings the females indulge in, Vasey is clear that they are not truly homosexual. A female may engage in female-female mounting, but that doesn't mean she isn't interested in males. Females often mount males, apparently to encourage them to mate more. Once they had evolved this behaviour, it was easy for them to apply it to other females as well.

In some cases, there is a fairly straightforward evolutionary reason why animals engage in homosexual behaviour.

Take male fruit flies. In their first 30 minutes of life, they will try to copulate with any other fly, male or female. After a while, they learn to recognise the smell of virgin females, and focus on them.

The males are using homosexual behaviour as a roundabout way to fertilise more females

This trial-and-error approach may look rather inefficient, but actually it is a good strategy, says David Featherstone of the University of Illinois at Chicago, US. In the wild, flies in different habitats may have slightly different pheromone blends. "A male could be passing up an opportunity to have viable offspring if they are hardwired to only go for a certain smell," says Featherstone.

Male flour beetles use a distinctly sneaky trick. They often mount each other, and go so far as depositing sperm. If the male carrying this sperm mates with a female later, the sperm might get transferred – so the male who produced it has fertilised a female without having to court her.

In both cases, the males are using homosexual behaviour as a roundabout way to fertilise more females. So it's clear how these behaviours could be favoured by evolution. But it's also clear that fruit flies and flour beetles are a long way from strictly homosexual.

Other animals really do seem to be lifelong homosexuals. One such species is the Laysan albatross, which nests in Hawaii, US.

Among these huge birds, pairs are usually "married" for life. It takes two parents working together to rear a chick successfully, and doing so repeatedly means that the parents can hone their skills together. But in one population on the island of Oahu, 31% of the pairings are made up of two unrelated females. What's more, they rear chicks, fathered by males that are already in a committed pair but which sneak matings with one or both of the females. Like male-female pairs, these female-female pairs can only rear one chick in a season.

Same-sex coupling is a response to a shortage of males

The female-female pairs are not as good at rearing chicks as female-male pairs, but are better than females that go it alone. So it makes sense for a female to pair up with another female, says Marlene Zuk of the University of Minnesota in Saint Paul, US. If she did not, she might manage to mate but would struggle to incubate her egg and find food. And once a female forms a pair-bond, the species' tendency towards monogamy means it becomes life-long.

There is even a subtle advantage for the females. The system means that they can get their eggs fertilised by the fittest male of the group, and pass his desirable traits on to her offspring, even if he is already paired with another female.

But once again, the female albatrosses are not inherently homosexual. The Oahu population has a surplus of females as a result of immigration, so some females cannot find males to pair with. Studies of other birds suggest that same-sex coupling is a response to a shortage of males, and is much rarer if the sex ratio is equal. In other words, the female Laysan albatrosses probably wouldn't choose to pair with other females if there were enough males to go round.

So perhaps we've been looking in the wrong place for examples of homosexual animals. Given that human beings are known to be homosexual, maybe we should look at our closest relatives, the apes.

Bonobo sex also cements social bonds

Bonobos are often described as our "over-sexed" relatives. They engage in an enormous amount of sex, so much so that it's often referred to as a "bonobo handshake", and that includes homosexual behaviour among both males and females.

Like the macaques, they seem to enjoy it, according to Frans de Waal of Emory University in Atlanta, Georgia, US. Writing in Scientific American in 1995, he described pairs of female bonobos rubbing their genitals together, and "emitting grins and squeals that probably reflect orgasmic experiences".

But bonobo sex also plays a deeper role: it cements social bonds. Junior bonobos may use sex to bond with more dominant group members, allowing them to climb the social ladder. Males that have had a fight sometimes perform genital-to-genital touching, known as "penis fencing", as a way of reducing tension. More rarely, they also kiss, perform fellatio and massage each other's genitals. Even the young comfort each other with hugs and sex.

Bonobos show that "sexual behaviour" can be about more than reproduction, says Zuk, and that includes homosexual behaviour. "There's a whole range of behaviours that fit in well with how evolution happens that now include homosexual behaviour." In fact, female bonobos still have sex when they are outside their reproductive period and can't get pregnant.

They don't show a consistent sexual orientation

Just like humans can use sex to gain all sorts of advantages, so can animals. For instance, among bottlenose dolphins, both females and males display homosexual behaviour. This helps members of the group form strong social bonds. But ultimately, all concerned will go on to have offspring with the opposite sex.

All these species might be best described as "bisexual". Like the Japanese macaques and the fruit flies, they switch easily between same-sex and opposite-sex behaviours. They don't show a consistent sexual orientation.

Only two species have been observed showing a same-sex preference for life, even when partners of the opposite sex are available. One is, of course, humans. The other is domestic sheep.

In flocks of sheep, up to 8% of the males prefer other males even when fertile females are around. In 1994, neuroscientists found that these males had slightly different brains to the rest. A part of their brain called the hypothalamus, which is known to control the release of sex hormones, was smaller in the homosexual males than in the heterosexual males.

That is in line with a much-discussed study by the neuroscientist Simon LeVay. In 1991, he described a similar difference in brain structure between gay and straight men.

How could this preference for other males be passed on to offspring?

This seems quite different from all the other cases of homosexual behaviour, because it is hard to see how it could possibly benefit the males. How could this preference for other males be passed on to offspring, if the males do not reproduce?

The short answer is that it probably doesn't benefit the homosexual males themselves, but it might benefit their relatives, who may well carry the same genes and could pass them on. For that to happen, the genes that make some males homosexual would have to have another, useful effect in other sheep.

LeVay suggests that the same gene that promotes homosexual behaviour in male sheep could also make females more fertile, or increase their desire to mate. The female siblings of homosexual sheep could even produce more offspring than average. "If these genes are having such a beneficial effect in females, they outweigh the effect in males and then the gene is going to persist," says LeVay.

While male sheep do show lifelong homosexual preferences, this has only been seen in domesticated sheep. It's not clear whether the same thing happens in wild sheep, and if LeVay's explanation is right it probably doesn't. Domestic sheep have been carefully bred by farmers to produce females that reproduce as often as possible, which might have given rise to the homosexual males.

So LeVay and Vasey still say that humans are the only documented case of "true" homosexuality in wild animals. "It is not the case that you have lesbian bonobos or gay male bonobos," says Vasey. "What's been described is that many animals are happy to engage in sex with partners of either sex."

Homosexual behaviour doesn't challenge Darwin's ideas

The funny thing is, biologists should have predicted this. When Darwin was developing his theory of natural selection, one of the things that inspired him was the realisation that animals tend to have far more offspring than they seem to need. In theory a pair of animals need only have two offspring to replace themselves, but in practice they have as many as they possibly can – because so many of their young will die before they manage to reproduce.

It seems obvious that this built-in need to keep reproducing would manifest itself in a powerful sex drive, one that might well spill over into mating while females are infertile, or same-sex matings. Victorian scientists saw animals having more offspring than seemed necessary: today we see animals having more sex than seems necessary.

"Homosexual behaviour doesn't challenge Darwin's ideas," says Zuk. Instead there are many ways it can evolve and be beneficial.

We may never find a wild animal that is strictly homosexual in the way some humans are. But we can expect to find many more animals that don't conform to traditional categories of sexual orientation. They are using sex to satisfy all sorts of needs, from simple pleasure to social advancement, and that means being flexible.