Commuters had a "miracle" escape when a 44-tonne machine toppled on to a Hull road at rush-hour, a court has heard.
The pile-driving rig fell across Tower Street on the evening of 10 December 2007 during construction of a hotel.
Balfour Beatty Ground Engineering and Multibuild Ltd were fined a total of £45,000 at Hull Crown Court on Thursday for breaching health and safety laws.
The Health and Safety Executive (HSE) said: "It is nothing short of a miracle that no-one was killed or injured."
Both companies had earlier pleaded guilty to breaching the Health and Safety At Work Act.
Balfour Beatty was fined £25,000 and ordered to pay £17,676 in costs. Multibuild Ltd was fined £20,000 and ordered to pay £18,687 costs.
The court heard that a piling machine, used to drive building supports into the ground, fell over and rolled across the road before demolishing a wall opposite.
An HSE investigation found that the main contractor, Multibuild Ltd, was responsible for providing a stone platform for the machine to work from, but had failed to design or install it correctly.
Balfour Beatty Ground Engineering Ltd, as a specialist sub-contractor, had the responsibility for safely carrying out the work.
After the hearing, HSE inspector Dave Redman said: "This incident could easily have resulted in disaster... given it occurred during the peak of the evening rush hour.
"It is every company's responsibility to ensure that employees and members of the public are not exposed to danger from heavy construction machinery.
"There is extensive guidance governing safe working in this sector, and we hope today's prosecution serves to remind people of their duties so that we don't witness an incident of this kind again."