Murray served in the Second World War, being appointed commanding officer of the 1st Battalion, Gordon Highlanders in 1941. In June 1942 the battalion, forming part of the 153rd Infantry Brigade, was shipped to Egypt, where his unit took part in the Second Battle of El Alamein. Murray was seriously wounded in the early stages of the battle and only returned to active service again in April 1943. After a brief period as temporary General Staff Officer Grade I of the 51st Division, Murray was given command of the 153rd Infantry Brigade in the same division. After a period of rest and refit in Algeria the brigade saw action in the Allied invasion of Sicily, after which it was shipped, with the rest of the division, in November 1943 to England for training and preparation for the Allied invasion of Normandy. Landing in Normandy on the afternoon of D-Day, Murray saw nearly constant action with his brigade until August when he was ordered to Italy to take command of the 6th Armoured Division, after its previous commander, Gerald Templer, was wounded. The division, operating in Italy, was involved in the fighting on the Gothic Line in late 1944 before being withdrawn into reserve and then joining V Corps for the Spring 1945 offensive in Italy. Following the breaking of the Axis defences in the Argenta Gap by the 56th and 78th Infantry Divisions, the 6th Armoured Division was released to exploit across country. Advancing north-west to the River Po, the division linked up with units of the United States Fifth Army, under Lieutenant General Lucian Truscott, advancing from the south to cut off Axis forces in Bologna. By 8 May the division was crossing the Austrian frontier becoming the first element of the British Eighth Army, under Lieutenant General Richard McCreery, to enter German territory. Murray was mentioned in despatches for his services in Italy, and appointed a Companion of the Order of the Bath in 1945. Although he held an appointment as actingmajor general, Murray's permanent rank was still only major at the end of the war because of his relative youth. In August 1945 he was advanced to temporary major general, war substantive colonel. His substantive rank was advanced to full colonel in December 1946, and again to major general in January 1948.
Postwar career
After the war, Murray was appointed Director of Personal Services in 1946 and then General Officer Commanding1st Infantry Division in 1947 in which role he was posted to Palestine and was mentioned in dispatches for services in Palestine between March and September 1947. He went on to become District Officer Commanding Northumbrian District and the Territorial50th Infantry Division in 1951. Relinquishing command of the 50th Division and the Northumbrian District in August 1953, Murray saw action again as GOC 1st Commonwealth Division in the Korean War. He relinquished the command in November 1954. In 1955, he was appointed GOC-in-Chief of Scottish Command in the temporary rank of lieutenant general and Governor of Edinburgh Castle. The lieutenant general's rank was made substantive in May. In 1958, Murray became Commander-in-ChiefAllied Forces Northern Europe. He relinquished the appointment in July 1961, having been promoted to full general in 1959. He retired from the British Army in September 1961. He maintained his links with the army, retaining the honorary Colonelship of the Cameronians until 1964.