Fatal rail accidents - crushed, smashed, severed, rolled over - were hardly unknown before the Tay Bridge disaster, " writes Charles McKean. But, as he adds with macabre relish, "drowning was novel."

The collapse of the Tay Bridge was a calamity, not merely for the 72 unfortunates who died, but for shattering the faith of Victorian society in modern technology. The longest bridge in the world at that time, spanning the "tormented tidal water" of the Tay, it had seemed to promise that humans could not just fly in the face of nature, but master it. The stormy night of December 28, 1879, proved otherwise, and the once gung-ho community of railway pioneers and their financiers were rocked to the core by the reverberations of this tragedy.

Battle for the North is not simply the story of that grim event, however. It is more interesting than that. The building of the Tay Bridge, and the problems associated with its construction that contributed to its collapse, were the product of the ferocious commercial rivalry between two railway giants, the North British Railway Company and the Caledonian Railway, whose flouncy rival hotels bookend Princes Street in Edinburgh.

As McKean suggests, had the companies joined forces rather than pursued such cut-throat competition, neither the Tay nor the Forth bridges would probably have been built. The reason these estuaries had to be bridged was because, in the fight to gain possession of the routes to the north beyond Edinburgh and Glasgow, since Caledonian Railway owned the line through the centre of Scotland, North British had to pay whenever it used its tracks. Which, naturally, Caledonian made as expensive and awkward as possible.

Professor of Scottish architectural history at Dundee University, McKean is not the most graceful of writers, but what he lacks in literary panache he more than makes up for in the depth of knowledge and insight he brings to this absorbing subject. Starting by describing the climate of entrepreneurial excitement of Scottish railway mania in the mid-1800s, he moves on swiftly from the days when railways were so slow they would stop to pick up passengers who stuck out their hand, to analysing the engineering sophistication that went into the design of such impressive and experimental structures as the Tay bridge.

At the heart of the book is the revelation that engineer Sir Thomas Bouch, who designed the bridge and was subsequently made scapegoat for its collapse, has been unfairly maligned. McKean has discovered statements by witnesses - not used at the inquiry into the collapse - showing that there had been complaints about the bridge's safety months before it toppled, issues traceable to damaged girders that meant carriages bounced as much as nine inches as they crossed. One or two passengers were so alarmed by the bumpiness of the ride that they refused ever to travel that way again.

McKean concludes that while Bouch was disastrously disinterested in the finer details of construction work, his design was essentially sound, and he cannot be blamed. If there is any one culprit, probably it was the surveyors whose report, prior to the bridge's design, indicated that the bed of the Tay was solid bedrock. Only when it was well underway did Bouch learn that the centre of the estuary was a morass of sand and gravel. The structural adjustments this forced him to make may have contributed to the bridge's weakness.

The Tay disaster forms the centrepiece of this richly textured history, but McKean cleverly keeps up the momentum after the grisly episode is over, describing the ramifications of that night and how they influenced the building of the replacement bridge, and its partner, the far more complex bridge across the Forth. His descriptions of the Forth bridge's design and construction are among the most gripping in the book. The ingenuity and courage of the engineers and labourers on this phenomenal edifice are awe-inspiring.

It's sobering to note that more died in the construction of these two remarkable bridges than drowned when that ill-fated train was pitched into the Tay. The stories of these men, of course, have been considered less newsworthy than the victims of the worst night in British railway history. Until now, that is.

Battle for the North: The Tay and Forth Bridges and the 19th Century Railway Wars, Charles McKean, Granta, GBP20. Charles McKean is at the Edinburgh International Book Festival on August 23.