Stafford was posted to South Africa in October 1899 to serve in the Second Boer War, in command of the 26th Field Company, Royal Engineers, where he participated in the advance on the Boer capital at Bloemfontein, including the engagements at Poplar Grove and Karee Siding in March 1900, after which he was promoted to lieutenant colonel from 14 April 1900, remaining in the Transvaal until August 1902. For his services during the operations in South Africa, Stafford was menmtioned in despatches and received the Queen's South Africa Medal with three clasps, and the King's South Africa Medal with two clasps, before being appointed a Companion of the Most Honourable Order of the Bath (C.B.) on 26 June 1902.