HONOLULU — Many sunscreen makers could soon be forced to change their formulas or be banned from selling the lotions in Hawaii.

State lawmakers passed a measure this week that would ban the sale of sunscreens containing oxybenzone and octinoxate by 2021 in an effort to protect coral reefs. Scientists have found the two substances can be toxic to coral, which are a vital part of the ocean ecosystem and a popular draw for tourists.

Consumers would only be allowed to buy sunscreen with the chemicals if prescribed by a health care provider, though the measure itself doesn't ban online purchases or tourists from bringing their own to Hawaii.

It would become the first state to enact a ban on the chemicals if Democratic Gov. David Ige signs the bill; he has not indicated whether he will.

Similar legislation failed last year, after it pitted environmental scientists against businesses and trade groups that benefit from the $2 billion market for sun care products in the U.S.

This is "a first step to help our reef and protect it from deterioration," said Hawaii state senator Donna Mercado Kim, a fellow Democrat who introduced the measure. Although other factors contribute to reef degradation, "hopefully, other jurisdictions will look at this legislation and follow suit."

"This is the first real chance that local reefs have to recover," said Craig Downs, a scientist whose 2015 peer-reviewed study found oxybenzone was a threat to coral reefs. "Lots of things kill coral reefs, but we know oxybenzone prevents them from coming back." It also affects sea urchins and kills algae, a source of food for sea turtles, he said.

He found as much as 14,000 tons of sunscreen lotion ends up in coral reefs annually.

Opponents are skeptical of the science.

"What we're really concerned with is that there aren't very many independent studies out there that have gone for peer review," said Tina Yamaki, president of the Retail Merchants of Hawaii. She said the ban might discourage people from buying sunscreen products from local brick-and-mortar stores. The American Chemistry Council also opposed the bill, citing concerns over the dangers of sun exposure.

"It's a feel good measure," said Democrat Sharon Har, one of four lawmakers who voted against the bill. "Yes, we must protect the environment -- it is our number one resource -- but at the end of the day, studies have pointed to global warming, human contact, coastal development" as other significant threats to coral.

Many manufacturers already sell "reef-friendly" sunscreens, and companies can deplete current inventory ahead of the ban in 2021, Downs said.

Edgewell Personal Care, which makes Banana Boat and Hawaiian Tropic sunscreen lotions, said it makes products free of the two chemicals. The company "will continue to ensure we comply with all relevant regulations concerning oxybenzone and octinoxate."

"We have so many problems with coral bleaching, and there is already so much contamination," said Dr. Yuanan Lu, a professor and director of the environmental health laboratory at the University of Hawaii, who applauded the passage. "We have so many people who come to Hawaii, and some of the sunscreen ingredients can be toxic, harmful to marine systems."