Harbour Law produced a rapid late charge to make Laura Mongan the first female trainer to win the St Leger after odds-on favourite Idaho unseated jockey Seamie Heffernan on the home straight.
Mongan had never saddled a horse in a Classic before the famous race in Doncaster on Saturday, but was in the winners' enclosure after 22-1 shot Harbour Law bolted down the outside to claim a sensational victory under George Baker.
Idaho was strongly fancied to win the final Classic of the year for Aidan O'Brien, but Heffernan crashed to the turf with three furlongs to go after the 8-11 favourite appeared to stumble when well placed.
Housesofparliament, another of O'Brien's three entries, chased down leader Ventura Storm, but it was Harbour Law who timed his run to perfection to win in a pulsating finish.
Ventura Storm, ridden by champion Silvestre De Sousa, was second and Housesofparliament third under Colm O'Donoghue.
Harbour Law became the first Epsom-trained winner since 1969 and trainer Mongan told Channel 4 Racing: "It's amazing, a bit surreal... I did a lot of screaming!"
A steward's enquiry did not result in any punishment for the incident which left Heffernan on the deck, both the jockey and Idaho escaping without injury.