Comcast Corp. agreed to pay $950,000 and cancel debts for 20,000 Xfinity customers in Massachusetts to settle a civil investigation by the state attorney general into deceptive advertising over "lock-in" prices that actually escalated over contract periods because of broadcast television and regional sports fees, court documents show.

Consumer activists say hidden fees in cable bills can boost monthly TV bills by 25 percent. A California class action lawsuit claimed that Comcast earns $2 billion a year from them nationally.

When thousands of Comcast customers in Massachusetts learned of the higher cable bills because of the fees, they dropped their TV service but also incurred termination fees of $240 to cancel long-term contracts, according to the Massachusetts Attorney General's Office.

As part of the settlement reached last week, Comcast will issue refunds to Massachusetts consumers who paid early termination fees after downgrading their service or being involuntarily disconnected by Comcast between January 2015 and March 2016. Comcast cooperated with the investigation.

The settlement includes $700,000 for refunds and $250,000 that the attorney general will use to pay for consumer initiatives and costs related to the Comcast investigation.

"Comcast stuck too many Massachusetts customers with lengthy, expensive contracts that left many in debt and others with damaged credit," Attorney General Maura Healey said. The law-enforcement agency said that the cost to consumers could be 40 percent over the advertised price for cable service because of fees. Comcast said the fees help cover the higher cost of those broadcast and cable channels.

Comcast denied wrongdoing, saying that it was avoiding protracted and costly litigation with the settlement. The Philadelphia company also said it had "enhanced disclosures" in its advertising.

"While we disagree with the allegations," Comcast spokesperson Jennifer Moyer said Tuesday, "we are committed to partnering with Attorney General Healey and others who share our commitment to improving the experience of our customers in all respects."

In June, Consumer Reports launched the national "What the Fee?!" campaign in Philadelphia by delivering to Comcast's headquarters a petition with 110,000 signatures asking that it be more transparent about buried fees in bills, such as monthly surcharges for broadcast television stations, local sports networks, and DVRs.

Jonathan Schwantes, senior policy counsel for Consumer Reports, said, "We applaud Massachusetts for taking action to protect their constituents from this deceptive marketing." Millions of customers nationwide have been lured into "contracts by this kind of advertising to find that fees keep getting more expensive," he said.

He added that the consumer group urges other states to follow Massachusetts and "crack down on the cable industry's abuse of these types of add-on charges."

In California, plaintiffs attorneys have sued Comcast in federal court over fees for broadcast television and regional sports networks, calling them "bogus."