"This is just one small step toward protecting and restoring the resiliency of Hawaii's reefs," Ige said at a signing ceremony for the bill, which takes effect in 2021.
He said the state would need to continue other efforts to protect coral, including fighting invasive species, pollution from land runoff and climate change.
Sunscreen containing oxybenzone and octinoxate will only be available to those with a prescription from a physician.
Others will have to buy sunscreens without these chemicals or bring their own sunscreen with them to Hawaii.
Scientists have found the two substances can be toxic to coral reefs, which are a vital part of the ocean ecosystem and a popular draw for tourists.
Both are widely used in sunscreen, with oxybenzone present in the blood of 96 percent of Americans, according to the Environmental Working Group.
State Sen. Roz Baker, who represents south and west Maui, said the bill has enormous significance because coral is such a fundamental part of a larger ecosystem important to the health of the planet.