Gates was one of the first cadets at the United States Military Academy at West Point when he was appointed as a cadet on 2 March 1801. He graduated on 6 March 1806, and was commissioned in the Army as a second lieutenant in the Regiment of Artillerists. He was the 11th cadet to graduate West Point and was ranked first in the Class of 1806. He served in garrison at forts along the Atlantic seaboard from 1806 to 1812. He was promoted to first lieutenant on 3 November 1807.
In the War of 1812 he served as acting adjutant of Regiment of Light Artillery, and Aide-de-camp to Brevet Brigadier GeneralMoses Porter in 1813, being engaged in the capture of York in Upper Canada on 27 April 1813. He was promoted to captain on 3 March 1813. Gates then participated in the bombardment and capture of Fort George on 27 May 1813. He was placed in command of Fort Independence, Massachusetts from 1813 to 1815. This coincided with British capturing Castine, Maine in 1814 which created the fear that any part of the New England coast might be subject to attack but no attacks were made against Massachusetts. The war ended with the news of the Treaty of Ghent had been signed in early 1815.
He was assigned to Fort Washington, Maryland from 1835 to 1836 and then served in the Seminole War in Florida from 1836 to 1838. He fought against the Seminole Indians in defense of Fort Barnwell on April 12, 1836. In June of that year he was court-martialed for cowardice, having failed to retrieve the bodies of slain soldiers outside his bulwark, resulting in their being mutilated by the Seminoles. Gates transferred to the 2nd Artillery Regiment on August 4, 1836. He was promoted to lieutenant colonel of the 3d Artillery on 17 December 1836. Gates arrested Seminole leader Osceola on October 21, 1837 during peace negotiations at Fort Marion in St. Augustine, Florida. Osceola was sent to Fort Moultrie near Charleston, South Carolina where he died a few weeks later. He was in the combat of Locha-Hatchee on January 24, 1838, in the Cherokee Nation, while transferring the Indians to the West. He returned to Florida from 1839 to 1842 and served in garrison at Fort Pickens.
He served at Fort Moultrie from 1842‑43 and in Savannah, Georgia from 1843 to 1844 before returning to Fort Moultrie from 1844 to 1846. He was promoted to colonel in command of the 3rd Artillery Regiment on 13 October 1845 which made him one of the highest-ranking officers in the Army. He served in the War with Mexico, from 1846 to 1848, as Governor of Tampico, Mexico. He served as the commander of Fort Adams in Newport, Rhode Island from 1848 to 1853.
Late in 1853 Gates and his regiment were ordered to be stationed in California. Gates was on board, along with hundreds of his soldiers and their families, the ill-fated steamer SS San Francisco when it was wrecked in a storm on 24 December 1853. An investigation of the incident found Gates to be delinquent in this duties and he was placed on waiting orders from 1854 until 1861.
With the outbreak of the Civil War in April 1861 the Union needed to maximize its resources and Gates was given an active assignment, despite being 73 years old. In December 1861 he assumed command of Fort Trumbull in New London, Connecticut. He was retired from the Army on 1 June 1863, under the retirement law of 17 July 1862, for having served in the Army for more that 45 years. Due to wartime needs, however, he continued to command Fort Trumbull until he was reassigned in March 1864 to Fort Constitution near Portsmouth, New Hampshire. He remained at Fort Constitution until his full retirement in 1867 after 66 years of military service. After the Civil War, Gates was breveted as a brigadier general for "Long and Faithful Service in the Army" to rank from March 13, 1865.