Gregory, born in London on 28 December 1776, was the fifth son of Benjamin Way (1740–1808), FRS, of Denham Place, Buckinghamshire, MP for Bridport in 1765, and of his wife Elizabeth Anne (1746–1825), eldest daughter of William Cooke, provost of King's College, Cambridge.
His grandfather, Lewis Way (died 1771), director of the South Sea Company, and descendant of an old west-country family, first settled in Buckinghamshire.
Way was brought in as captain of the 5th foot on 20 January 1803, and, after serving in the Channel Islands, embarked with his regiment in the expedition under Lord Cathcart for the liberation of Hanover in 1805; but the vessel in which he sailed was wrecked off the Texel, and he was taken prisoner by the Dutch.
In accordance with orders received there, the expedition sailed for the River Plate, arriving at Montevideo in the beginning of June 1807, where it joined the force under General John Whitelocke, of which Way was appointed assistant quartermaster-general.
He took part in the Battle of Roliça on 17 August, when, on gaining the plateau with a few men and officers of his regiment, he, when charged by the enemy, was rescued from the bayonet of a French grenadier by the humanity of General Brenier, and made a prisoner.
At the Battle of Talavera on the night of 27 July, Way took part with his regiment, under Major-general Rowland Hill, in the gallant repulse at the point of the bayonet of the French attack of the heights on the left of the British position.
On his return to England in 1812 with the skeleton of the 29th Regiment (about a hundred effective men), Way by considerable exertion reformed the corps, and embarked a second time for the Peninsula in 1813.
On the abolition of his staff appointment in Scotland he was nominated, on 7 November 1822, colonel of the 3rd Royal Veteran Battalion, which was disbanded in 1826, when Way was placed on half-pay.