Although he had been a strong advocate of annexation to the United States, Gray was a strong states'-rights Democrat and was elected as a delegate to the state Secession Convention, where he voted in favor of taking the state out of the Union. In November 1861 he was elected to represent the Houston district in the first Confederate House of Representatives. There he served on the House Currency and Judiciary committees and the special committee on homesteads for disabled soldiers. As a vigilant guardian of Texas financial interests, Gray secured a separate branch of the Treasury Department for the Trans-Mississippi region. Like most Texans, he favored direct taxation and heavy export duties to support the government and took a keen interest in the Sequestration Acts owing to the fact that much Texas land was owned by absentee Northern interests. At the same time he supported a strong central government, favoring, for example, nationalizing of the Confederate railroad system. He was a friend and confidential advisor of Jefferson Davis, as well as a supporter of conscription and exemption from the draft of overseers of slaves. Gray was defeated in his 1863 reelection campaign by Anthony Martin Branch. At the end of his term he became a volunteer aide to Gen. John B. Magruder and served at the battle of Galveston. In 1864 President Davis appointed him fiscal agent for the Trans-Mississippi Department, a position that he accepted with some reluctance. He was unsuccessful in raising funds to retire the Confederate debt in the region and thus left Gen. Edmund Kirby Smith's army virtually without financial means through the final months of the war.
After the war Gray returned to his Houston law practice, which he built into one of the largest in the South, and was elected first president of the Houston Bar Association in 1870. In 1873 he toured Europe. In 1874 Gov. Richard Coke appointed him associate justice of the Texas Supreme Court, upon the resignation of William P. Ballinger, but Gray resigned within two months, on April 18, due to worsening pulmonary tuberculosis. He died in Houston on October 3, 1874, and was buried in the Glenwood Cemetery. In 1876 the Texas legislature named Gray County in his honor. Gray reportedly assumed his middle initial, which stands for no other name, in later life. He was a devout Episcopalian, a charter member of Christ Church in Houston, and an active Mason.
29° 45.879, -095° 23.214