Uber has agreed to put a cap on its tactic of raising prices during emergencies and natural disasters.

The agreement with New York State Attorney General Eric Schneiderman came after the service received sharp criticism for raising prices during extreme weather that hit New York earlier this year. In some cases, passengers were charged more than US$100 for rides of just a few miles.

Schneiderman had held out the prospect of prosecution under New York’s price gouging statute as he talked to the company.

Under the deal, Uber will still exercise “surge pricing”—a dynamic adjustment of fares to suit demand—but the price it charges will be limited during “abnormal disruptions of the market,” which typically refers to weather-related emergencies and natural disasters, but also encompasses things like power failures, civil disorder and wars.

At those times, Uber will be limited to “the normal range of prices it charged in the preceding sixty days.” When calculating that rate, there will be an additional exclusion on “the three highest prices charged on different days during that period.”

While the agreement just covers New York state, Schneiderman’s office said Uber is going to roll out a similar cap nationwide.

“Uber is expected to announce a national policy to limit pricing in emergencies that is based on this agreement,” it said in a statement.

Uber CEO Travis Kalanick carefully praised the agreement in a statement and promoted it as a model for possible future regulatory agreements with other arms of government.

“This policy intends to strike the careful balance between the goal of transportation availability with community expectations of affordability during disasters,” he said. “Our collaborative solution with Attorney General Schneiderman is a model for technology companies and regulators in local, state and federal government.”