Starfish are again brightening up tide pools along the California coast after being ravaged by a mysterious wasting disease, and the colorful invertebrates have undergone a remarkable genetic adaptation that is protecting them from the deadly pathogen, a new study has found.

The genealogical transformation, observed throughout the species’ range, is a rare example of microevolution in the wild and an encouraging example of resilience in the face of environmental peril, says the UC Merced study, published this week in the scientific journal Proceedings of the National Academy of Sciences.

“We have known for some time that evolution of populations can be rapid, theoretically in as little as a single generation, but empirical examples come mostly from terrestrial environments,” said Michael Dawson, a professor at UC Merced and co-author of the study. “This is a great example that adaptation also can be very rapid in the oceans.”

The study documented a 74-fold increase since 2013 in the number of surviving offspring of the ochre star, the purple or orange starfish most commonly seen in California intertidal regions. That alone is extraordinary given that the illness, dubbed sea star wasting disease, wiped out more than 80 percent of the population — millions of starfish — between 2012 and 2015.

Even more significant, though, were the results of a comparison of DNA samples taken from ochre stars before and after the outbreak. It turns out their genetic code had changed since the epidemic.

“This revealed consistent changes between the original population and survivors, between the original population and new juveniles, and across geographic locations,” said Lauren Schiebelhut, a UC Merced biologist and lead author of the study. “Subsequent generations will be the progeny of survivors and so we expect the genetic shift to be maintained.”

Schiebelhut attributed the finding to a pre-existing genetic variation in the survivors of the die-off. The disease resistant gene was apparently passed onto their offspring, allowing the modified starfish to repopulate the California coast.

The disease, which is believed to be a type of parvovirus, first began killing sea stars in Southern California in the summer of 2013, but the problem quickly spread northward. The situation worsened quickly, becoming a kind of tidelands horror show, with the arms of starfish rotting and falling off, their skeletons disintegrating and their bodies wasting away until they were little more than gooey blobs.

The pathogen wiped out sea stars along huge swaths of the coast from Mexico to Alaska. The wasting disease was eventually detected in 20 varieties of starfish, ravaging sunflower stars, the largest sea stars in the world. Short-spined sea stars and giant sea stars were also hit hard.

But it was the species known as Pisaster ochraceus, the ochre star, that took the brunt of the damage. Only one out of every five ochre stars along the 100-mile stretch north of San Francisco survived, researchers said.

Scientists believe some sort of environmental stress caused sea stars to become more susceptible to the pathogen, such as warmer water, ocean acidification or other changes caused by global warming. It is believed the pathogen spread in the water — almost like a common cold — among the dense, often interwoven, populations of starfish.

The initial worry was that the starfish would never be able to recover and starfish prey would proliferate and alter the ecosystem. Starfish feed on a variety of invertebrates, including mussels, sea urchins, clams and snails. Without starfish, these species could wipe out algae, plants and other sea life that thrive when hungry snails and urchins are controlled.

“The species we studied — the ochre sea star — was literally decimated. It is a keystone species, so changes in abundance cascade through the ecosystem,” Dawson said. “Those knock-on effects illustrate the inter-connectedness among species and how changes can have unanticipatedly broad consequences.”

What actually happened was not something anybody predicted. Huge numbers of baby sea stars began appearing in previously devastated areas. In one 2014 study site, on a reef called Terrace Point, off Santa Cruz, researchers found more juvenile sea stars than had been seen in 15 years of monitoring.

One hypothesis is that the plague caused the sea stars to go into reproductive mode, shooting out sperm and eggs as an evolutionary response to stress. Whatever the cause, researchers said, the sea star larvae that came from the few animals with plague-resistant genetics survived and thrived.

It means the starfish now hugging the rocky shore are living examples of natural selection in process, Dawson said.

“That ochre sea stars had the capacity to adapt to events as dramatic as this is remarkable, and perhaps re-assuring that future climate change may be withstood by some species,” Dawson said. “But the ochre sea star is perhaps a species with greater resilience than many, and with projected climate swings expected to be more extreme, the ochre sea star’s resilience is perhaps a small, distant bright light on a pretty stormy sea.”

The research team plans to continue studying this, including genetic testing on some of the 20 other species impacted by the infection, in search of a blueprint for how marine species might adapt to future changes in their environment.

“We don’t know the proximate nor the ultimate cause” of the deadly outbreak, Dawson said. “That should make us worry. We should all be asking ‘Why?’ and ‘What can we do to reduce the chance of something like this occurring again.’”

Peter Fimrite is a San Francisco Chronicle staff writer. Email: pfimrite@sfchronicle.com Twitter: @pfimrite