Bain was born into poverty in Dundee, Scotland on 6 March 1860 to Andrew Bain and Eliza Thomson. At the age of 16, he enlisted in the British Army and in 1878 he was sent to Pretoria, the capital of the Transvaal, annexed by Britain the previous year. He fought for the British against the Zulus in Natal in 1879. From 1880 to 1882 he was stationed in India.
After leaving the Army he returned to Scotland where he trained as a fitter. As a skilled artisan, he became active in the labour movement and became familiar with the thought of Thomas Carlyle, a Scottish socialist. He became active in socialist circles, joined the Scottish Land & Labour League and met William Morris, a leading figure in European socialism, in Edinburgh.
In 1890 he moved to South Africa, initially settling in Cape Town. He immediately became known as a zealous proponent of socialism. Bain moved north to Kimberley and soon after to the Transvaal (which had after the victory at Majuba in 1881 regained its independence from Britain as the Zuid Afrikaanse Republiek).
He settled in Johannesburg, which had become a major mining settlement after the discovery of gold in 1886, and became active in the Labour Union, launched in August 1892.
During the 1890s Bain was politically active in a range of ways, including spying for the Kruger government in the Transvaal and Natal. He became editor of the Johannesburg Witness in 1899 and became a leading figure in Johannesburg Trades Council (founded October 1893). With Tom Mathews (Cornish-born ex-US mining union activist in Butte, Montana) and Johannesburg Trades Council's secretary Robert Noonan (aka Robert Tressell, author in 1914 of The Ragged Trousered Philanthropists) he founded the International Independent Labour Party.
When the Second Boer War broke out between the ZAR and Britain in October 1899, Bain joined the Transvaal forces and fought for his adopted country. On 31 July 1900, the day Johannesburg fell to the British, he was captured there and faced the prospect of a charge of treason, but was eventually treated as a POW on the basis of his naturalisation to the Transvaal. He was held in Ceylon, and after his release in 1903 returned to Johannesburg.
From then to 1905 Bain maintained a low profile in the labour movement. But in 1906 the Transvaal Independent Labour Party was formed and, after its merger with another grouping, Bain was elected president. Bain went to work on a mine outside Pretoria in 1908 and remained active in politics and trade unions.
In 1913 he became a full-time organiser with the Trade Union Federation and almost immediately was plunged into the greatest industrial conflict ever experienced in Southern Africa. From May to July 1913 as secretary of the Strike Committee he was the leader of the strike that started at the Kleinfontein Mine east of Johannesburg and soon escalated to a Transvaal-wide industrial revolt (of white workers). In June Bain led efforts to initiate sympathy strikes at various neighbouring mines and on the 20th was arrested on a charge of 'incitement to strike'. He was released on bail and on 29 June a general strike was called.
On 4 July 1914, in a meeting between the strike leaders, Prime Minister Louis Botha and then-minister Jan Smuts, agreement was reached on the basis of full reinstatement of all miners who had been dismissed and an undertaking by the government to consider all the grievances of the trade unions. Botha and Smuts managed to persuade the mine owners, and the settlement was concluded.
However, Smuts was to have his revenge for the 'defeat' of 1913. A railway strike declared (without Bain's approval) in January 1914 led Smuts to mobilise his newly organised citizens' forces and seize key railway institutions. A general strike was proposed, but on 10 January a warrant for Bain's arrest was issued. Bain and fellow labour leaders barricaded themselves into their headquarters and on 13 January the Federation announced that affiliated unions had balloted in favour of the strike. However, on 15 January the Trades Union building was surrounded by police and soldiers, including artillery, and Bain and his colleagues had no option but to surrender. In February he was deported to Britain.
By November 1914 he and other deportees were back on the Rand, but – partly as a result of World War I – never regained the initiative. In October 1919 he was admitted to Johannesburg General Hospital. After writing a letter to a newspaper from his death bed, urging readers to vote for Labour and Socialist candidates in the forthcoming local election, he died on 29 October.