The first railways at the Cape were privately owned. The Cape Town Railway and Dock Company started construction from Cape Town in 1859, reaching Eerste River by 1862 and Wellington by 1863. Meanwhile, by 1864, the Wynberg Railway Company had connected Cape Town and Wynberg. For the moment, railway development at the Cape did not continue eastwards beyond Wellington because of the barrier presented by the mountains of the Cape Fold Belt.
Formation of CGREdit
The discovery of diamonds, and the consequent rush to Kimberley that started in 1871, gave impetus to the development of railways in South Africa. Shortly afterwards, in 1872, the Cape Colony attained responsible government under the leadership of Prime Minister John Molteno, who presented plans for an enormous network of railways to connect the Cape Colony's main ports to its interior and, importantly, to the Diamond fields. In his very first speech to the Cape Parliament he announced the purchase of all existing lines and the founding of the Cape Government Railways.
The announced expansion was to see the construction of a network over ten times more extensive than the total length of railway that existed in the whole of southern Africa at the time. The management of this system – which was to become the nucleus of the future South African Railways – initially fell under his Public Works Department, until July 1873, when Molteno established a separate Railway Department under the renowned engineer William Brounger.
The first few rudimentary lines at Cape Town were built at dimensions close to 4 ft 8+1⁄2 in (1,435 mm) standard gauge, the British Empire's standard. However their width, designed for England's landscape, made it impossible at the time to penetrate the mountains of the rugged southern African escarpment. Most of the sub-continent was effectively landlocked. In 1871 Molteno had written to the British Governor of the Cape Henry Barkly about the gauge which was used to penetrate the mountainous terrain near Trieste in modern Italy, believing it would work in crossing the South African mountains. A narrower gauge enabled tighter turns and traversing steeper terrain. When the first elected Cape government took power the next year, its select committee set the gauge for all new railways at 3’-6”. The use of a dual system was briefly kept, to ease the transition for the existing wider lines, but in only a few months the government standardised all railway development on what became known as the "Cape Gauge" of 3 ft 6 in (1,067 mm).
Although it was first meant just to ease construction of railways through mountainous terrain, this gauge later went on to become the standard for all railways in southern and central Africa.
The government's 1872 plan was for lines to strike northwards, from the three ports of Cape Town, Port Elizabeth and East London, towards Kimberley and the developing hinterland. These three lines became known as the "Cape Western", "Cape Midland" and "Cape Eastern" lines respectively. They were intended to bring the towns of southern Africa's vast hinterland into direct railway connection with the country's ports, thus driving the development of the interior and building an export economy.
The Cape Western Line was charted by the Prime Minister himself (allegedly with only a map, pen and ruler). Cape Town was cut off from the highland interior by a triple barrier of steep mountain ranges, but the lines nonetheless progressed fast inland, once the primary obstacle of the Hex River Mountains was overcome in 1876 with a major system of bridges and tunnels. 1876 also saw the building of a new central station for Cape Town, and over the next few years the line was rapidly extended through the Karoo desert to the town of Beaufort West, De Aar, and thence to Kimberley.
The Cape Midland Line was begun in 1872, when the Cape Government took over the rudimentary and incomplete line of the Port Elizabeth and Uitenhage Railway Company. However building accelerated massively over the next few years, with twin lines reaching northwards to Graaff-Reinet, and eastwards to Grahamstown. These connected with the Cape Western Line at De Aar and thus to Kimberley.
The Cape Eastern Line was built partially to serve the frontier, and its network of military forts. The port of East London was likewise chosen partly for strategic reasons, being the closest port to the frontier for landing and transporting troops. The line was begun in 1873, when the Prime Minister turning the first spades for both the East London harbour and the Eastern Railway Line on 20 August 1873. Though frontier wars disrupted construction from time to time, the line reached Queenstown in 1880. 
By 1885 the separate sections were connected and the Cape Western line reached Kimberley, marking the end of an epic which had begun in 1872, with the network completed faithfully according to the original 1872 plans. From an initial total of 92 kilometres in 1872, the Cape was now criss-crossed with over 2,000 kilometres of railway.
Considerable development and economic growth followed the construction of the railway system, and the news of the Cape's immense railway programme inspired similar moves in neighbouring states, such as the project of the Natal Government Railways to extend its few miles of railway inland towards the Drakensberg, and President Burgers' ill-fated attempt to link the Transvaal Republic to Lourenço Marques.
In 1886 gold was discovered in the South African Republic (the Transvaal), setting off the Witwatersrand Gold Rush. The Cape government and the government of the Orange Free State (OFS) reached an agreement, by which the Cape Government Railways would build and operate a railway line, through the OFS, to the rapidly growing city of Johannesburg. This line reached Bloemfontein (the capital of the OFS) in 1890, and the first trains operated from Cape Town to Johannesburg in 1892. In 1897 the OFS government took over control of its portion of the line.
Formation of SAREdit
The Cape railway network played a significant role in supporting and supplying the British forces during the Second Boer War. After the war, when the Union of South Africa was formed in 1910, all railways in South Africa, including the CGR, the Natal Government Railways and the Central South African Railways, were taken over by the newly formed South African Railways (SAR).
According to a 2017 study, "Built largely to support the early mining industry, the Cape Colony’s railway substantially reduced the cost of transport to the interior and account for 22–25 percent of the increase in the Colony’s labor productivity from 1873 to 1905... traffic data for 1905 suggest that the railway contributed to the expansion of the mining areas and to the growth of the Western Cape district on the basis of domestic demand."
- The Royal Commonwealth Society, 1898, "Proceedings of the Royal Colonial Institute". The Institute, Northumberland Avenue, London, W.C. p. 26.
- Burman 1984, p. 50.
- "Cape Colony - british, south, dutch, africa, european, population and country". gluedideas.com.
- SABC, 14 August 1954, John Bond. "John Molteno: Founder of the South African Railways", p. 3.
- Davenport, D.E. A Railway Sketch of South Africa. 1882. Cape Town
- "Full text of "Proceedings of the Royal Colonial Institute"". archive.org. Retrieved 1 September 2017.
- "Postojnska Jama in Slovenia, the Suedbahn and the visit of John Charles Molteno: Their influence on the Development of Railways in South Africa". zrc-sazu.si.
- “Report of the Select Committee appointed by the House of Assembly on 20th of May 1873 on the Question as to what Gauge should be adopted on the Line of Railway from Wellington to Worcester”. Parliament of the Cape of Good Hope. 1873.
- "Cape Gauge - From Ox-wagon to Iron Horse | The Heritage Portal". www.theheritageportal.co.za. Retrieved 1 September 2017.
- Bond J.: They were South Africans. London: Oxford University Press. 1956. Chapter 19, The Makers of Railways: John Molteno. p.170.
- Bergen M.G.: Storm over South Africa: The Rutherford Chronicles. Partridge Africa, Johannesburg. 2016. ISBN 1482861682. p.146.
- Schmidt J.: Call of the Muezzin - Cape to Riyadh. Partridge Africa, Johannesburg. 2014. ISBN 1482803976
- Royal Colonial Society: Proceedings of the Royal Colonial Institute. Northumberland Avenue, London. 1898. p.26. "The Railway System of South Africa".
- Burman 1984, pp. 52–63.
- Burman 1984, pp. 64–78.
- Burman 1984, pp. 79–90.
- F. Statham: Blacks, Boers, & British: A Three-cornered Problem. MacMillan & Co. 1881. p.42.
- Burman 1984, pp. 95–96.
- kim (20 September 2016). "Aloes Railway station". South African History Online. Retrieved 1 September 2017.
- Herranz-Loncán, Alfonso; Fourie, Johan (2018). ""For the public benefit"? Railways in the British Cape Colony". European Review of Economic History. 22: 73–100. doi:10.1093/ereh/hex010. hdl:2445/119919.
- Kleingeld, Christo (2003). A South African Railway History Archived 16 July 2011 at the Wayback Machine. Accessed 14 December 2009.
- Paxton, Leith, and David Bourne (1985). Locomotives of the South African Railways. C. Struik (Pty) Ltd., ISBN 0-86977-211-2
- Burman, Jose (1984), Early Railways at the Cape, Cape Town: Human & Rousseau, ISBN 0-7981-1760-5