In 1789, Murray obtained a commission into the 71st Foot, reaching the rank of captain in 1794, and saw service in Flanders (1794–95), the West Indies, England and Ireland. In 1799 , he was made a lieutenant-colonel, entering the Quartermaster General's Department and making his considerable reputation as Quartermaster General (1808–11) during the Peninsular War, under the Duke of Wellington, and receiving promotion to Colonel in 1809. After a brief period as Quartermaster General in Ireland, Murray returned to the Peninsular Campaign as Major-General (1813–14), and was invested with the Order of the Bath in 1813. During the Peninsular War he was present at the battles of A Coruña, Talavera, Busaco, Fuentes de Oñoro, Vittoria, Nivelle, Nive, Orthez and Toulouse. His Peninsular Gold Medal had six clasps - only the Duke of Wellington, with nine clasps, Sir Dennis Pack and Lord Beresford, with seven each, had more clasps to their medal.