Membership contracts at 700 gyms were unfair because they tied in customers for between one and three years, the High Court has ruled.
Ashbourne Management Services Ltd drew up membership agreements and collected payments from about 300,000 customers of small gyms in the UK.
It demanded immediate payment of the full sum - often many hundreds of pounds - for the whole minimum period if people left after a few months.
Ashbourne is planning to appeal.
Many members had seen their circumstances change so it was no longer affordable or practical to go to the gym.
If they refused to pay for the minimum term, Ashbourne put pressure on them by threatening to damage their credit rating by referring the debt.
The firm had registered nearly 17,000 defaults with credit reference agencies by July 2009, the court heard.
The judge, Mr Justice Kitchin, said that the minimum period was a trap into which the average consumer was likely to fall.
Other elements that he ruled to be unfair included refusing to allow a customer to cancel a contract by notifying the gym, and Ashbourne demanding payment even when the member had a genuine dispute about the quality of the gym.
He ordered that Ashbourne stop using or relying on its current standard contracts and from using unfair terms in the future, saying that 12 months would be a more acceptable contract duration.
Ashbourne has been told not to report or threaten to report consumers to credit reference agencies, where the term requiring payment is unfair.
However, the judge did decide that the contracts could not be treated as credit agreements, for which a licence would be required at Ashbourne.
John Clayton-Wright, managing director of Ashbourne, said the decision on credit agreements was a victory for the business. He said he would appeal against the other rulings.
He said the contracts offered by Ashbourne were now more flexible, and that "nobody forced" people into signing the previous contracts with lengthy terms. He argued that the duration of the contract was core and could not be deemed to be unfair.
He said he would not pay back any amounts to those who had left early and paid the full amount.
The Office of Fair Trading (OFT), which brought the action, said the ruling would have implications for other businesses which gave customers black marks on their credit records.
"We have received many complaints about Ashbourne's contracts, and many consumers have felt pressured into paying sums of money that they believed they did not owe," said Jason Freeman, of the OFT.
"We are pleased that the court has confirmed that these practices are unlawful, and this should bring peace of mind to many people who have fallen into the trap of signing up to these lengthy gym contracts.
"Unfair terms that unreasonably bind consumers into long contracts they cannot leave, and heavy-handed collection techniques, have no place in businesses' dealings with consumers.
"This ruling should help traders to understand where the boundaries lie, and sends a warning that if they cross the line, the OFT and local trading standards services can take action."