John Hamilton Gray was born in 1814 at St. George's, Bermuda, British West Indies. He was of English and Loyalist ancestry, the son of William Gray, British Vice Consul, Virginia, United States. His paternal grandfather, James Gray was a Massachusetts Loyalist who came to Nova Scotia at the close of the Revolutionary War.

He was educated at King's College, Windsor, Nova Scotia, and graduated with the degree of Bachelor of Arts in 1833. He studied law and was admitted to the Bar of New Brunswick as attorney on October 17, 1835, and as barrister on February 9, 1837.

He located at Saint John, New Brunswick, and engaged in the practice of his profession. He was created Queen's Counsel in 1853 and received an Honorary Degree of Doctor of Civil Law at the University of New Brunswick in 1856. He took an active interest in militia affairs and was promoted to Lieutenant Colonel and to command the Queens Rangers of New Brunswick in 1854.

In 1853 he married Miss Eliza Ormond in Dublin, Ireland. By this marriage there was a family of seven children.

He ran unsuccessfully in Saint John County and City for the House of Assembly at the general election of October 9, 1846 and was first elected to the House of Assembly as one of the members for Saint John County and City at the general election of June 20, 1850. He was re-elected at the general elections of June 1854, June 24, 1856 and April 23, 1857, and sat until the dissolution of the Legislature in 1861. At the general election of June 5, 1861 he was defeated, but was again elected at the by-election held March 18, 1863 made necessary by the death of the sitting member, John Jordon. He was again defeated at the general election of March 3, 1865 on the Confederation issue of which he was in favour. He was re-elected at the general election of June 6, 1866, and sat as a member until July 1867, when he resigned in order to stand for election to the House of Commons.

During the years 1857-1858, John Hamilton Gray acted as an arbitrator between Great Britain and the U.S.A. under the Treaty of Washington. In 1860 he was appointed commissioner to settle the tenant right question in Prince Edward Island.

He was a member of the Executive Council of New Brunswick without portfolio on the administration of the Hon. John R. Partelow from September 1851 to October 31, 1854. From June 1856 to June 1857 he was Premier and Attorney General in his own administration and from June 21, 1866 to June 1867, he was Speaker of the House of Assembly.

John Hamilton Gray was a delegate to the Charlottetown Conference on the subject of Maritime Union in 1864 and to the Quebec Conference in the fall of 1864 on the issue of Confederation. He later became known as one of the Fathers of Confederation.

At the first general election for the House of Commons in September 1867, he was elected by acclamation as member for Saint John County and sat in that Parliament until 1872 when he retired.

On July 3, 1872, he was appointed a puisne judge of the Supreme Court of British Columbia. He retained this position until his death.

He died on June 5, 1889, at Victoria, British Columbia.

Source - Speakers of the Legislative Assembly, Province of New Brunswick, 1786-1985. 1985, Legislative Assembly, Province of New Brunswick, Office of the Clerk, Fredericton, N.B.