Hartley was commissioned into the Army as a second lieutenant in the Royal Fusiliers on 13 July 1898, and was promoted to lieutenant on 2 August 1899. He served with the 2nd battalion of his regiment in South Africa during the Second Boer War, where he was present at the Battle of Colenso (December 1899), engagements at Pieter′s Hill, Hussar Hill and Hlangwani (February 1900), and the subsequent relief of Ladysmith in late February 1900. In the following months he served in the Transvaal, including the engagement at Rooidam (May 1900). After the end of the war in South Africa in June 1902, Hartley resigned his commission on 26 November 1902.