Mackay graduated from the University of Sydney in 1904 and taught physics there from 1910 until 1914, when he joined the Australian Imperial Force shortly after the outbreak of the First World War. He served with the 4th Infantry Battalion at Gallipoli, where he distinguished himself in hand-to-hand fighting at the Battle of Lone Pine. In April 1916, he assumed command of the 4th Infantry Battalion on the Western Front and led it at the Battle of Pozières, Battle of Bullecourt and Battle of Broodseinde. He was promoted to brigadier general in June 1918, and led the 1st Infantry Brigade at the Battle of Hazebrouck, the Battle of Amiens and in the attack on the Hindenburg Line.