The fines flagged up the seriousness with which the justice system now treats safety failings where the public are at risk.
The penalties were immediately welcomed by both passenger safety groups and unions.
Engineering giant Balfour Beatty - responsible for track maintenance at the time - was fined £10 million and Network Rail £3.5 million for breaking safety rules before the crash.
The companies were also ordered to pay £300,000 each in costs.
Until today, the largest fine ever imposed in the English courts was £2 million on Thames Trains following the 1999 Paddington rail crash. The company had pleaded guilty to two health and safety charges.
This summer gas utility company Transco was fined £15 million in Scotland after a leaking gas main led to an explosion that killed four members of a family.
Sentencing them, Mr Justice Mackay - who has spent 30 years involved in similar cases - said he had guarded against over-reaction in sentencing.
"But I regard Balfour Beatty as one of the worst examples of industrial negligence in a high risk industry I have seen.
"These were breaches of a general duty to the public at large. Something over three-quarters of a million passengers would have been put at risk by passing over this area.
"Both companies fell below appropriate standards. Balfour Beatty's failure lay at the top of the scale."
Balfour Beatty is no longer in the business of railway maintenance as Network Rail has taken over from Railtrack and taken maintenance "in house".
He said: "No one can predict the future, but the risks of such a tragedy had been reduced by the action of Network Rail.
"The elimination of one of the indefensible features of the 1996 privatisation - the separation of the ownership and control of the track from its maintenance - is now gone. Perhaps that is one good thing resulting from this disastrous affair."
Network Rail was convicted of breaching the Health and Safety Act last month and Balfour Beatty had admitted the charge earlier.
Four people died and 102 were injured when the King's Cross to Leeds train came off the tracks at 115mph on October 17 2000.
The prosecution maintained the derailment was an accident waiting to happen and occurred because of a cavalier approach to safety.
In evidence, some maintenance and track inspection practices were described as a Fred Karno circus and a shambles.
The rail which broke - causing the train to fly off the track - had disintegrated.
Defective monitoring meant it had been left virtually uninspected in the months before the crash.
Mr Justice Mackay said the failures affected a substantial part of a busy high speed line for 21 months.
The severity of the fines imposed today on Network Rail and Balfour Beatty over the Hatfield train crash were welcomed by the Safe Trains Action Group (Stag).
Stag vice chairman Carol Bell said: "We have said that there have to be bigger, swingeing fines for companies and it's good to see that there have been in this case."
Mrs Bell, who was injured in the 1997 Southall train crash which claimed seven lives, added: "There was a record fine (of £1.5 million for the Great Western train company) after Southall and I am pleased that much higher fines have now been handed out.
"The size of these fines sends a message to companies that they must take full regard of safety."
TUC general secretary Brendan Barber said: "Today's decision shows that the courts are now beginning to take health and safety breaches more seriously. But the families of those killed will still feel cheated that no senior executives are to face punishment as a result of their safety crimes.
"The Government urgently needs to address the fact that all the courts can do in a case like this is to fine a company.
"What is necessary is both a new offence of corporate killing, with a wider range of penalties available, and new legal duties that make directors directly responsible for the health and safety of their staff and customers."
The judge highlighted the problem of fining a company which has no shareholders where "the profits it makes are all ploughed back into the railway system.
"In reality therefore, every £1 fined is a pound they cannot spend on railway safety."
Ordering the companies to pay towards the prosecution costs - estimated alone to be £8.5 million - Mr Justice Mackay said the disaster led to a massive investigation.
There had been national concern "over the third of a sorry quartet of rail accidents at the turn of the century".
- More about:
- Balfour Beatty
- Network Rail
- Railroad Traffic