Couples exchange vows during a mass wedding for 25 same-sex partners at Seattle First Baptist Church on Sunday in Seattle, Wash.

The answer may lie in epigenetics, or how the expression of genes is controlled by “temporary switches” known as epi-marks, researchers from the National Institute for Mathematical and Biological Synthesis explained in a study released Tuesday.

Sex-specific epi-marks are usually “erased” from generation to generation.

But when they do not disappear, they can be passed from father to daughter or mother to son, resulting in homosexuality in children, scientists suspect.

“Transmission of sexually antagonistic epi-marks between generations is the most plausible evolutionary mechanism of the phenomenon of human homosexuality,” Sergey Gavrilets, the study’s co-author, said in a release.

Researchers have long believed that sexual orientation had some hereditary component.

However, scientists say that homosexuality, in terms of evolution, cannot be solely genetic, because the trait would eventually disappear given that homosexuals aren’t expected to reproduce.

Epi-marks, on the other hand, are thought to have an evolutionary advantage that keeps them within the population.

For instance, some epi-marks work to protect a female fetus from becoming too masculine if testosterone spikes in late pregnancy.

“These epi-marks protect fathers and mothers from excess or underexposure to testosterone — when they carry over to opposite-sex offspring, it can cause the masculinization of females or the feminization of males,” William Rice, the study’s lead author, told U.S. News & World Report.

Rice said that epi-marks are “highly variable” and only those that are especially strong would potentially lead to homosexual children.

The evolutionary biologist said that while his theory still needs to be tested on parents and their children, it is the most plausible explanation so far.

“We've found a story that looks really good," Rice said. “This can be tested and proven within six months. It's easy to test. If it's a bad idea, we can throw it away in short order."