Magarey served in the Australian Imperial Forces during World War II, serving in the 7th Division in 1940. At the end of 1940 he sailed for the Middle East and Syria, where he served in the 2/11 Australian Army General Hospital. In recognition of his distinguished services he was mentioned in dispatches. After Japan entered the war Major Magarey's unit was recalled to Australia and later transferred to New Guinea and the Kokoda Trail as part of the 2/6 Australian Field Ambulance, serving as Senior Medical Officer at Alola on the Kokoda Trail.