Key West, the sunny city at the southernmost tip of Florida, voted this week to ban the sale of sunscreen containing chemicals believed to harm coral reefs.

The law’s supporters see it as a crucial step toward protecting the great treasure of the Florida Keys: the world’s third-largest barrier reef ecosystem, which runs nearly 150 miles, hosts thousands of species of marine life, and attracts divers and snorkelers from around the globe.

The measure, which the City Commission approved Tuesday in a 6-to-1 vote, will ban sales of sunscreens containing the chemicals oxybenzone and octinoxate. The legislation will go into effect on Jan. 1, 2021.

“Our coral has been under attack by a number of stressors,” Mayor Teri Johnston said. “We just thought if there was one thing we could do, to take one of the stressors away, it was our responsibility to do so.”