The Health and Safety Executive brought two charges against Balfour Beatty and Austrian tunnelling consultant Geoconsult, alleging that they failed to discharge their duty to ensure the safety of their own staff and the public.
Workers managed to get out before the Heathrow Express tunnel, being built using the new Austrian tunnelling method, collapsed on 21 October 1994 causing millions of pounds of damage and disruption at the airport.
On the opening day of the trial at London's Central Criminal Court, Justice Cresswell said Balfour Beatty had admitted the charges. Geoconsult denied the charges but has withdrawn its legal representation. Justice Cresswell said the trial would continue.
Opening for the crown, Hugh Carlisle said the Health and Safety at Work Act, under which the firms were charged, covered near misses as well as accidents in the workplace.
He said: "This is about one of the biggest near misses in years. It was only by chance that a major disaster did not happen." Carlisle said Geoconsult's role was to supervise the tunnel design and monitor site data.
He said the firm ignored 14 warnings about system defects that made the work unsafe before it started.
The data showed that a collapse was likely two weeks before the incident. The company could have halted work until the repairs were carried out but failed to do so.
"A warning should have been given and a risk assessment made," said Carlisle. "They were the watchdogs who didn't bark." He said buildings at Heathrow were still suffering from the effects of the collapse.
The HSE suspended all work using the new Austrian tunnelling method after the collapse, causing delays on the Jubilee Line Extension where the system was also used.
The trial is expected to resume later in the week.