In summer 1940, Gray enlisted in the Royal Canadian Naval Volunteer Reserve (RCNVR) as officer candidates. Realizing succession to higher ranks would be slow in the RCNVR, he subsequently made application to join the Royal Navy Fleet Air Arm.
By 1941, Hammy had been promoted to the rank of Sub-Lieutenant and was sent to North Africa in 1942 following further training. For the next two years, he would gain valuable experience flying Hawker Hurricanes and other of the Navy's shore-based aircraft.
As a Lieutenant (N), Hammy's wishes to be transferred to an operational carrier squadron were realized in August 1944 when he transferred to HMS Formidable as the Senior Pilot. Later that month Hammy would see action against the mighty German Battleship Tirpitz - sister ship to the Bismarck, which terrorized the North Atlantic for a brief period in May 1941. Throughout the month, Gray would be involved in four separate attacks against the Tirpitz. Hammy would be awarded with a Mentioned in Dispatches for his outstanding work during the last attack on the 29 August against the Tirpitz.
April 1945 would see HMS Formidable and Hammy being sent to join the British Pacific Fleet in their fight against the Japanese. On 6 August 1945 the United States dropped an atomic bomb on the city of Hiroshima, the first of two atomic bombs against dropped on the Japanese mainland. By this time, many involved in the conflict realized that the war may soon be over. On 9 August 1945, the same day the United States dropped a second atomic bomb (this time on Nagasaki), Gray lost his life when leading two flights of Corsairs against Japanese naval ships in Onagawa Bay.