In 1879, Pirie obtained a commission to the 1st Dragoon Guards as a second-lieutenant, but was transferred to the 7th Dragoon Guards shortly afterwards and spent time stationed in Aldershot and Norwich. In 1881 he was promoted to Lieutenant and was transferred to the 4th Dragoons a year later. He was stationed in Egypt during the Anglo-Egyptian war of July-September 1882, serving as an extra Aide de Camp to Sir Gerald Graham. He was consequently commended in despatches, and awarded the Egypt Medal, presented to him in 1883 at a royal levee at St James Palace, overseen by the Prince of Wales. He was exchanged to the 1st Life Guards later that year.