The Cardiff Railway came into being from the need to service Bute Docks, so as to provide facilities for the traffic to and from the Docks. The railway was only 11 miles in length, a fact which belied its importance, since it provided both the Taff Vale Railway and the Rhymney Railway, inter alia, with access.
On 6 August 1897 the Bute Docks Company became the Cardiff Railway Company, and the line between Heath Junction and Treforest was opened. This opening was filled with difficulties, because Treforest Junction was on the Taff Vale Railway, at the same point as the TVR's junction with the Barry Railway. Here the Barry syphoned off large amounts of coal traffic for transport to Barry Docks. The TVR had no intention of allowing more to be syphoned off by another company, and so it defied the Act of Parliament which had authorised the junction and appealed against its opening on the grounds that it was unsafe.
A delay of some years was followed by an agreement over the design of the junction and the successful running of a ceremonial opening train, which was promptly followed by the TVR, with the support of the Barry, removing the junction; again on the grounds that it was unsafe. It was obvious to all concerned that the TVR was deliberately attempting to crush this rival before it became too big, but little could be done about their petty objections - particularly as the junction was on their railway. Regular coal trains never used the junction, as the Cardiff Railway gave up the battle at this point and suggested a merger between it, the TVR, and the Rhymney Railway. Although both companies involved agreed with this, the Barry and Pontypridd, Caerphilly and Newport Railway objected on the grounds of unfair competition, particularly as the TVR was one of the world's most profitable railways (although the Barry was a close second).
Ultimately the Cardiff was forced to acknowledge that it would never be a successful company in its own right, but remained independent until the Railways Act 1921, when it became a constituent part of the Great Western Railway on 1 January 1922.
The Cardiff Railway had 36 steam locomotives, all built by private manufacturers, which were acquired by the GWR on 1 January 1922. For details see Locomotives of the Great Western Railway#Cardiff Railway