Presenter Tim Dunn was given the rare opportunity to enter Bramhope Tunnel - which carries the main Leeds to Harrogate line between Horsforth and Arthington - by Network Rail during maintenance work.
The tunnel was built by navvy labour in 1849 and was one of the longest in Britain when it first opened.
Tim, who had never been inside a mainline tunnel before, was accompanied by Network Rail engineer Ian Wilson when they visited at midnight in January.
The presenter also explores the Grade II-listed north portal, which was built to resemble a castle in woodland, and visits the memorial in Otley to the men who lost their lives during the construction project.
Twenty-four of the 2,300 navvies hired to build the tunnel died, many as a result of blasting accidents involving gunpowder. They spent four years living in 300 lineside 'bothies', with single men sometimes sleeping 17 to a hut. The village school had to be extended to accommodate navvy children, there was a long-running dispute over water being siphoned from farmers and the town well for the railway camp, and there was even a riot when contractors tried to restrict the beer supply reaching the labour force.
Tim Dunn said: “Bramhope Tunnel has one of the most magnificent entrance portals you’ll ever see. I’m really pleased we are able to showcase it in this series of The Architecture the Railways Built. It’s fascinating to hear how important the railways were to Leeds in general and I’m grateful to Network Rail for giving us such amazing access to such a wonderful place, and also to Leeds Museums for letting us borrow John McGoldrick as to tell us all about it too.”
The episode airs at 8pm on Monday on Yesterday, with catch-up available on UKTV Play.