The Dulas Valley Mineral Railway was incorporated in 1862 to bring coal from the Onllwyn area north-east of Neath to the quays there, and in the following year was reconstituted as the Neath and Brecon Railway. The line was opened as far as Onllwyn in 1863.
The directors allowed a contractor John Dickson a free hand in building the line and when he became bankrupt the company was in a desperate financial situation. Nevertheless, the line was completed to Brecon in 1867, and an offshoot to connect with the Swansea Vale Railway, giving better access to Swansea, was ready in 1873.
The larger Midland Railway acquired rights over the line and ran a heavy mineral train service for many years, although the remote and difficult course of the line was expensive to operate. After the 1922 "Grouping" of the railways, a pooling agreement led to the diversion of the heavy traffic to routes that were easier to work over, and the line reverted to a quiet and remote rural line.
The passenger service was withdrawn in 1962 and present-day (2017) traffic is confined to uncertain mineral business from Onllwyn to Neath.