On 1 June 1916, the 13th Battalion embarked at Alexandria for Marseilles, France, before being deployed to the Western Front. In mid-June, the battalion moved into trenches at Bois Grenier near Armentières, and on 13 July they relocated to Bailleul, in time for the Battle of the Somme.
On 29 August, Murray commanded A Company—which consisted of fewer than one hundred men—in a successful attack that captured Mouquet Farm under heavy fire. His men repelled four German counterattacks before he ordered them to withdraw. He remained in command until the next morning, when he fainted from loss of blood from two wounds he had sustained during the action. Murray was awarded the Distinguished Service Order for his service during the action, an event that was published in a supplement of the London Gazette dated 14 November 1916. He was later evacuated to England aboard the hospital ship Asturias, and admitted to the 4th General Hospital, London, where he was to share a ward with Albert Jacka and Percy Black, who were recovering from wounds received at Poziéres and Mouquet Farm respectively. After nearly six weeks of recuperation, he returned to the 13th Battalion in France on 19 October.
Following a period of patrols and trench raids, the 13th was relieved by the 5th Battalion on 6 December, and marched back to Ribemont, where Murray was granted leave to England. On 4 January 1917, he was Mentioned in Despatches. The battalion returned to the front in February, relieving the 15th Battalion at Gueudecourt. On 4 February, the battalion's commanding officer received the order to attack Stormy Trench; it was during this action that Murray would earn his Victoria Cross.
On the night of 4–5 February 1917, the 13th Battalion—with Murray commanding A Company—attacked the German position at Stormy Trench. Preceded by a heavy artillery barrage, A Company seized the right of the position after overcoming stiff resistance, consolidating their gains by setting up a makeshift barricade. The Germans counterattacked, prompting Murray to send an SOS signal to the artillery officer, calling for more support. Although repulsed, the Germans counterattacked twice more. On the third attack, Murray organised a twenty-man grenade bombing party and led them in a charge against their attackers, pushing them back to their original start line. On another occasion when the company lost some ground, Murray rallied his men and retook it. Between midnight and 03:00, the company maintained spasmodic bombing, repelling further assaults with the aid of artillery support. By 20:00 on 5 February, the 16th Battalion relieved Murray's company, which had only 48 survivors from the 140 who had begun the attack.