The Competition and Markets Authority (CMA) also fined distributor Flynn Pharma £5.2m for the 2,600% overnight price increase for the drug in 2012.
NHS spending on the capsules, used by 48,000 UK patients, rose from £2m a year in 2012 to about £50m in 2013.
Pfizer rejected the findings and said it would appeal against the decision.
UK prices for the drug were many times higher than in Europe, the CMA said.
Philip Marsden of the CMA said: "The companies deliberately exploited the opportunity offered by de-branding to hike up the price for a drug which is relied upon by many thousands of patients.
"These extraordinary price rises have cost the NHS and the taxpayer tens of millions of pounds."
Before 2012, Pfizer manufactured and distributed the drug, which was branded Epanutin.
Pfizer then sold the UK rights to distribute the phenytoin sodium capsules to Flynn Pharma, which de-branded the drug.
That allowed the firms to charge more for the drug because it was no longer subject to a pricing scheme agreed between the NHS and the drugs industry, the CMA said.
However, Pfizer said the drug was a loss-making product, and that the deal with Flynn "represented an opportunity to secure ongoing supply of an important medicine for patients with epilepsy".
"Pfizer believes the CMA's findings are wrong in fact and law and will be appealing all aspects of the decision," it said.
The drugs giant said the increased price of the drug was still 25% to 40% below the cost of an equivalent medicine by another supplier to the NHS.
But the CMA said by its calculations "all such losses would have been recovered within two months of the price rises."
Flynn Pharma said the CMA was "making a serious error" and that it would appeal in a bid to overturn the CMA's findings.
"It beggars belief that the CMA seeks to punish Flynn for selling phenytoin capsules at a significant discount to phenytoin tablets," said David Fakes of Flynn Pharma.
The firms have between 30 days and four months to reduce the price to a level acceptable to the CMA, and two months to appeal against the CMA decision to the Competition Tribunal.
The fine will go to the Treasury rather than the NHS directly, although the health service could try to seek damages.
'Best possible value'
Drugs industry body the Association of the British Pharmaceutical Industry said it "does not in any way support or condone the practice of 'price hikes' to generic medicines".
"Whilst we can't comment on individual companies and an appeal being made, it's appropriate that the complexities of this case are considered through the ongoing legal process," the organisation said.
The government is seeking to tighten up regulation of generic drugs price rises.
The Health Service Medical Supplies (Costs) Bill passed its third reading in the House of Commons on Tuesday.
A Department of Health spokesperson said: "Yesterday, our bill to ensure we can control high prices of generic medicines passed through the House of Commons - we are absolutely determined to ensure that no pharmaceutical company can exploit the NHS.
"We very much welcome the fines issued today, which show that any such exploitation will not be tolerated."