Ofcom has fined EE £6.3m and Virgin Media £7m for overcharging customers who ended their contracts early.
The telecoms regulator imposed the fines after 400,000 EE customers who ended their contracts early paid extra charges amounting to £4.3m.
Almost 82,000 Virgin Media customers were overcharged, totalling £2.8m.
Ofcom said it was "unacceptable" that customers were left "out of pocket", after the telecoms companies did not make clear the charges to be paid if customers ended their contract early.
The investigation found that, over a six-year period, EE miscalculated early-exit charges for customers who had been paying a discounted monthly price.
Affected customers were allowed to pay a lower price while they remained EE customers, but were treated as if they were paying another higher price if they wanted to leave.
Ofcom said: "These excessive charges disincentivised EE customers from switching to another provider, which is against Ofcom rules."
Not all affected customers paid the excessive charges, because some were subsequently waived by EE.
EE has now refunded more than £2.7m to customers that it has been able to identify.
Ofcom’s investigation also found that, for almost a year, Virgin Media levied early-exit charges that were higher than customers had agreed to when signing up to their contracts.
As a result of the probe, Virgin Media has now reduced its early-exit charges by at least 30% and reimbursed affected customers or made donations to charity instead.
However, Virgin Media has announced plans to appeal the fine, which it says is "not justified, proportionate or reasonable".
Gaucho Rasmussen, Ofcom’s director of investigations and enforcement, said: "EE and Virgin Media broke our rules by overcharging people who ended their contracts early. Those people were left out of pocket and the charges amounted to millions of pounds.
"That is unacceptable. These fines send a clear message to all phone and broadband firms that they must play by the rules, in the interests of their customers."