Uber’s practice of “surge pricing” — hiking prices during times of high demand, including holidays like New Year’s Eve or Halloween — is well-known to people who use the service. Now, the company has agreed to cap prices during natural disasters and other emergencies.

Eric T. Schneiderman, attorney general of New York state, announced the news Tuesday, saying that his office and Uber had agreed to limit surge pricing during these types of events.

The announcement covered Uber’s actions in the state of New York — which has a law against price gouging that was enacted in 1979 following increases in heating oil prices — but Uber has also announced changes to its surge methods across the country.

Uber said that during disasters or other emergencies, it would still hike prices in U.S. cities, but from now on it will institute a cap. The surge price will have to be below the price seen on the three most expensive non-emergency days during the preceding two months.

“This policy intends to strike the careful balance between the goal of transportation availability with community expectations of affordability during disasters,” Travis Kalanick, chief executive of Uber, said in a statement issued through Schneiderman’s office.

The agreement between Schneiderman’s office and Uber is good for three years and also expands to the UberX service.

Schneiderman and Kalanick both praised the agreement as a good example of government and technology companies working together, which has been a thorny area for Uber, as it and other car-dispatch services have been challenged by local governments (with difficulties in areas including Los AngelesMiamiAustin, Tex., and across Europe).

In addition, Uber said Monday that it would donate commissions from surge trips during emergencies to the American Red Cross (giving away 20 percent of the total fare).

UPDATE: This post originally said that Uber was banned in Los Angeles, which is incorrect. The city demanded that Uber halt service last year, but Uber said it had an agreement in place to operate statewide and continued service.