How did the ghoulish creatures known as anglerfish pull off the evolutionary feat that let them essentially take over the ocean’s sunless depths?

It took peculiar sex — extremely peculiar sex.

Scientists at Yale University have discovered that a burst of anglerfish diversification began some 50 million years ago as the ancestral line developed a bizarre strategy to ensure successful reproduction in the dark wilderness.

To mate, tiny males would clamp with sharp teeth onto the bellies of much larger females. Some males would let go after mating while others would permanently fuse into the females. The males that stayed attached became permanent organs for sperm production.

“We found that a cascade of traits, including those required for sexual parasitism, allowed anglerfishes to invade the deep sea,” Chase D. Brownstein, a graduate student in the ecology and evolutionary biology department at Yale who was the study’s lead author, said in a news release.

Today, there are more than 300 species of anglerfish, which makes them the most varied family of vertebrates in the ocean’s lightless zone. The region starts about 1,000 feet down — just beneath the photic zone, which gets enough sunlight to support photosynthesis and most of the sea’s plants — and descends for miles. The team’s study was published last week in the journal Current Biology.

Finding a mate in the deep sea can be extremely difficult because of the environment’s incomprehensibly vast size. By some estimates, the dark zone amounts to more than 97 percent of the planetary space inhabited by living things, mainly because the ocean plunges to a maximum depth of nearly seven miles. In contrast, land habitats make up less than 1 percent of the planet’s biosphere because the band of life is so narrow, making its volume quite small.