Hawaii on Tuesday became the first state to pass a law committing to the goals and limits of the Paris climate accord, defying President Trump, who announced last week that he would withdraw the United States from the historic agreement.

The state’s governor, David Y. Ige, signed two bills at a ceremony at the state’s capitol rotunda in Honolulu. One of the bills was explicitly geared toward reducing greenhouse gas emissions in accordance with the landmark goals adopted by world leaders with the Paris Agreement in 2015. The other will establish a task force to help the state improve soil health and remove carbon from the atmosphere.

He was joined by mayors from around the state, who signed an agreement to commit to the goals of the accord.

“Many of the greatest challenges of our day hit us first, and that means that we also need to be first when it comes to creating solutions,” Mr. Ige, a Democrat in his first term as governor, said in remarks before the signing. “We are the testing grounds — as an island state, we are especially aware of the limits of our natural environment.”