The Merthyr, Tredegar and Abergavenny Railway, also known as the Heads of the Valleys line, was a railway line which operated between 1860 and 1958 between the Monmouthshire town of Abergavenny and the Glamorgan town of Merthyr Tydfil in South East Wales.
The line can be traced back to the large bequest left by Richard Crawshay, proprietor of the Cyfarthfa Ironworks, to his nephew, Joseph Crawshay, in 1810. With his inheritance, Crawshay together with Matthew Wayne acquired the Nantyglo Ironworks from Hartford, Partridge and Co. in 1811 for £8,000. When Wayne retired from the partnership in 1820, Crawshay Bailey took his place. Crawshay Bailey became sole proprietor in 1833 upon the retirement of his brother. In the same year, he acquired the Beaufort Ironworks.
Crawshay Bailey was the driving force behind the development of tramroads in the Nantyglo area which served to bring raw materials to and from his various ironworks. First, in 1822, he opened a 5.5 miles (8.9 km) plateway known as Bailey's Tramroad between the Nantyglo Ironworks and a wharf on the Brecknock and Abergavenny Canal at Govilon. Here it met with the Llanvihangel Railway, a 3 ft 6 in (1,067 mm) line opened in 1811 which stretched 6.25 miles (10.06 km) to Llanvihangel Crucorney and an end-on junction with the Grosmont Railway. In February 1859, Crawshay and his partner Thomas Brown acquired the Beaufort Tramroad between Brynmawr and its junction with the Llanvihangel Railway at the canal wharf in Gilwern.
The next step for Bailey was part-conversion of the tramways into a standard gauge line connecting prosperous Merthyr with its reserves of coal and iron ore and Abergavenny which was in decline. The Act authorising the incorporation of the Merthyr, Tredegar and Abergavenny Railway obtained Royal Assent on 1 August 1859.