In what regulators are calling the largest refund in U.S. history by an internet provider to consumers, Charter Communications has agreed to give $62.5 million — and free subscriptions to HBO or Showtime — to New York customers who allegedly didn't receive the Internet speeds they were promised, according to New York Attorney General Barbara Underwood.

The settlement puts an end to a monthslong legal battle between the state of New York and the nation's second-largest cable company, whose subsidiary Time Warner Cable was accused of providing slow routers and modems to customers that prevented them from accessing the download speeds they had signed up for.

As many as 700,000 New Yorkers will be receiving the direct refunds. Another 2.2 million will be eligible for the free premium and streaming channels, which are collectively valued at more than $100 million, Underwood's office said in a release.

"This settlement should serve as a wake-up call to any company serving New York consumers: Fulfill your promises, or pay the price," said Underwood, who added that the action "sets a new standard" for corporate advertising.

Charter said the lawsuit stemmed from Time Warner Cable's advertising practices from before the two companies merged.

"We are pleased to have reached a settlement with the Attorney General on the issue of certain Time Warner Cable advertising practices in New York prior to our merger, and to have put this litigation behind us," Charter said in a statement. "Charter has made, and continues to make, substantial investments enhancing Internet service across the state of New York since our 2016 merger."

Data collected by the Federal Communications Commission show that roughly 93 percent of Charter's customers nationwide receive a median download speed that is on par with their advertised speed tier.

But many New Yorkers had complained that they were in the minority of users who were being left behind. Although Time Warner Cable had marketed speeds of up to 300 Mbps, subscribers to those and other plans suffered through stuttering on Netflix and other streaming services as the broadband network failed to deliver enough capacity to serve a smooth connection, New York alleged in its 2017 lawsuit.

As part of the settlement, Charter will give for free either three months of HBO or six months of Showtime to New York customers who don't already pay for the channels themselves through their monthly bill.

Each of the direct refunds will amount to $75 per affected subscriber, while as many as 150,000 customers will get an additional $75 for having lived with an "inadequate" modem for two years or more.