After a number of abortive attempts to link the market town of Masham, Wensleydale, the branch line was authorised by an Act of Parliament in 1871 and construction started in 1873. The line was delayed in opening for a full year as the railway company could not agree terms for the some of the land. Other problems were also encountered; when building an embankment across a peat bog just outside of the village of Wath, the railway builders found that their initial estimate of of earth would need to be increased threefold to traverse the bog beneath. The branch line opened on 9 June 1875 and services started the following day.
Traffic
The line was poorly used from the start. Passing to the London and North Eastern Railway in the 1923 grouping, the line continued to suffer from light traffic apart from a period during the Second World War when the local area was used for munition storage in the area around Tanfield station. In the run-up to D-Day, trainloads of 50 wagons were leaving the site to supply the operation with munitions. Both Tanfield and Masham stations had been provided with goods facilities in the station area. Tanfield had a passing loop in the station, but was only constructed with one platform. Masham had a goods yard directly next to the station platforms, but was also provided with a transhipment goods yard north of the station and across the Masham to Melmerby road for the narrow gauge railway supplying the reservoir building further west. A passenger train derailed between Tanfield and Masham on the 5 April 1926. 30 people were aboard the train and despite the train leaving the rails, there were no injuries. The cause was later attributed to newly laid rail on a bed of ash that had buckled in unseasonably hot weather.
A railway was built between Masham and the Leighton Wood area. This line was used to transport equipment and materials to the building of a reservoir at Roundhill for the Harrogate Corporation and the line was also used by the Leeds Corporation to build their reservoir at Leighton immediately downstream. The line opened in 1905 and was closed in 1930, some time after completion of both reservoirs.