Penicuik's original station on the Peebles Railway was a mile or so from its centre and not easy to access thanks to the hilly terrain. An approach by the townsfolk for a separate branch into the town was rejected, resulting in the local paper mills' proprietors - and other gentlemen from the district - establishing the Penicuik Railway Company to make progress with one independently, enabled by a Parliamentary Act of June 1870.
Although only 4¼ miles in length, the branch - engineered by Thomas Bouch and built by John Waddell - presented considerable challenges, costing about £12,000 per mile and crossing the River North Esk seven times. Two short tunnels were driven through spurs of land whilst a third, of 248 yards, was effectively created by covering the line as it passed close to the Roslin Gunpowder Mills. This iron structure was later dismantled, the mills having closed in 1954.
The branch opened to goods on 9th May 1872, slightly later than contractually stipulated, resulting in the contractor suffering a penalty of £10 per day. Passenger services were inaugurated on 2nd September.
Firth Viaduct (also known as Old Woodhouselee Viaduct) was the branch's most considerable feat - a ten-arched structure built mostly in rock-faced masonry, but with patch brickwork repairs in evidence. It curves gently to the north, reaching a height of 66 feet above the water. All the spans are semicircular and 35 feet in length, featuring brick arches of five rings. The three river piers - much higher than those at the west end due to the steep valley side - are skewed to align with the direction of flow, resulting in a stepped appearance to the faces of the arches they support. A low stone parapet is provided on both sides of the deck, surmounted by modern steel railings, although some of the original iron handrails remain extant.
Closed to regular passenger traffic in September 1951, the branch continued to carry freight until it succumbed to Beeching's reshaping on 27th March 1967, driven by the repairs necessitated by two landslips. Since then, the trackbed - including the viaduct - has been adapted to accommodate part of the popular Penicuik to Dalkeith Walkway. The structure had a Category B listing bestowed upon it in January 1971.