That long-awaited Hawaii vacation just got a little more complicated for Californians and other tropical holiday lovers who slather sunscreen on their pale skin between dips in the aqua blue water.

The state of Hawaii will ban two chemicals commonly used in sunscreens starting in 2021, a move that will force visitors from more temperate climes like San Francisco to begin using products that don’t harm the environment.

Hawaii Gov. David Ige signed legislation this week that will prohibit the sale or distribution of sunscreens that contain oxybenzone and octinoxate, which have been linked to widespread damage to coral reefs.

“This is not only the first in the country, but first-in-the-world legislation,” said state Sen. Mike Gabbard, who introduced the bill. “Jurisdictions all over the world will see this law as the gold standard, and they will be looking to replicate it.”

The Caribbean island of Bonaire is one of many places doing just that. The Dutch municipality heard about Hawaii’s law and is planning to enact a similar ban.

Sunscreen makers opposed the Hawaiian bill, as did some dermatologists, who worry about sunburns and skin cancer. But Gabbard said protecting the marine ecosystem is of utmost importance to the economy of Hawaii, which attracts 9 million tourists a year.

Coral are tentacled invertebrates that attach themselves to the ocean floor and to the skeletal structures of one another, obtaining energy from sunlight through the algae within them.

The structures, or reefs, they form protect coastlines from waves and provide habitat for an incredibly diverse array of marine life.

Studies have shown that oxybenzone and octinoxate, which filter ultraviolet radiation and are commonly found in cream-based sunscreens, cause bleaching in coral reefs. By changing the DNA in coral cells, the chemicals cause the cells to starve and die, according to the research.

One study, published in the U.S. journal Environmental Health Perspectives, showed that even small amounts of the chemicals made the algae in coral susceptible to viral infection. The killing, or bleaching, of the algae — which have a symbiotic relationship with the coral — is a death knell for the whole structure.

Most of the world’s reef systems are now being threatened by a combination of global warming, industrial pollution and human-produced products, which is why the sunscreen threat is being taken seriously by scientists.

Sun care products, including lotions and lip balms, bring in about $1 billion a year in the United States alone, and a lot of them are used in tropical vacation spots. But these products aren’t the only problem. Microplastics, ocean acidification, warming ocean temperatures and overfishing are ruining the world’s reef systems, according to marine scientists. If nothing is done, they say, 90 percent of the world’s coral could die by 2050.

As much as 6,000 tons of sunscreen a year ends up in the coral reefs in places like Hawaii, where people swim and snorkel, according to estimates by environmental groups and the World Trade Organization. In Maui alone, 55 gallons a day pour into nearshore waters, according to the Hawaii Department of Land and Natural Resources.

That, combined with sewage and pesticide runoff, killed off half of the islands’ coral reefs in 2014 and 2015, Gabbard said.

It’s also a problem elsewhere in the ecosystem. A team of Swiss agriculture department chemists recently discovered traces of commonly used ultraviolet filters found in sunscreens in the fish in mountain lakes and rivers downstream from wastewater treatment plants.

It is an indication that the chemicals may have been washed off in bathtubs and sinks and discharged from the treatment plants into the rivers. And the chemicals are known to bioaccumulate, meaning they are absorbed into the tissue of fish and accumulate over time.

The ban, signed into law Tuesday, appears problematic for pale-skinned, sun-worshiping environmentalists who love to snorkel and have an aversion to carcinoma. But Gabbard said many companies already provide sunscreens that don’t include the listed chemicals.

Once the ban goes into effect on Jan. 1, 2021, exceptions will be made for patients with prescriptions. The law also excludes skin care products intended for use as a cosmetic.

“We’re not going to have sunscreen police on the beaches of Waikiki,” Gabbard said.

“We applaud them and support what they are doing,” said Rusty Kelly, a director for the Coral Reef Alliance in Oakland, “but there is still more to do.”

The Consumer Healthcare Products Association argued that the two chemicals are safe, and complained that the law will ban at least 70 percent of sunscreens on the market.

“The health, safety and welfare of millions of Hawaii residents and tourists has been severely compromised,” the association said. “This irresponsible action will make it more difficult for families to protect themselves against the sun’s harmful ultraviolet rays, and it is contrary to the many concerns expressed by Hawaii’s medical doctors, dermatologists, and public health experts.”

Gabbard said the industry concerns are not credible.

“There is already a whole cottage industry that has safer products available to the public,” he said. “I’m hoping we can look back in 20 years and say this is when we turned the corner on pollution.”

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