In 1854, he was named Reporter of Decisions for the Massachusetts Supreme Judicial Court. While serving in this capacity, Gray edited sixteen volumes of court records, and also served as a counselor to the governor of Massachusetts on legal and constitutional questions. The quality of Gray's work earned him a reputation for historical scholarship and legal research. Gray was appointed to the Massachusetts Supreme Judicial Court as an associate justice in 1864. At age 36, he was the youngest appointee in the Court's history. Nine years later he was elevated to chief justice. While serving as chief justice, Gray hired Louis D. Brandeis as a clerk, becoming the first justice of that court to hire a law clerk.
United States Supreme Court
In December 1881, President Chester A. Arthur nominated Gray to fill the vacancy on the U.S. Supreme Court created by the death of Nathan Clifford. The United States Senateconfirmed his appointment shortly thereafter, and on January 9, 1882 he officially joined the Court. As he had been in Massachusetts, Gray was also the first U.S. Supreme Court justice to hire a law clerk. He used his own funds to pay the clerk's salary, as no government money was appropriated for this purpose at the time. Gray was one of the few Supreme Court appointees in the latter half of the 19th century who had not previously been a politician, and he maintained the opinion that law and politics were entirely separate fields. Two years after joining the Court, He wrote the majority opinion in Juilliard v. Greenman, the last of the post–Civil War Legal Tender Cases, which reaffirmed that Congress did have the power to issue paper money as legal tender. The 8–1 decision rested largely on prior court cases as well as an assessment of what the Framers of the Constitution intended to achieve through their grant of certain "Enumerated powers" to Congress in Article I, Section 8. The most enduring of his written opinions is the one he authored in Mutual Life Insurance Co. of New York v. Hillmon, which held that a declarant's out-of-court statement of his intention to do something or go somewhere in the future is admissible under the "state-of-mind" hearsay exception. "The letters in question were competent, not as narratives of facts communicated to by others, nor yet as proof that he actually went away from Wichita, but as evidence that, shortly before the time when other evidence tended to show that he went away, he had the intention of going, and of going with Hillmon, which made it more probable both that he did go and that he went with Hillmon, than if there had been no proof of such intention." This holding was subsequently codified in Rule 803 of the Federal Rules of Evidence, as well as the evidence laws in most states. Gray was also the author of the 1898 case United States v. Wong Kim Ark, ruling that "a child born in the United States, of parents of Chinese descent, who, at the time of his birth, are subjects of the Emperor of China, but have a permanent domicil and residence in the United States, and are there carrying on business, and are not employed in any diplomatic or official capacity under the Emperor of China, becomes at the time of his birth a citizen of the United States." 169 U.S. 649;705. He joined the majority in Pollock v. Farmers' Loan & Trust Co., a 5–4 ruling that the unapportioned income taxes on interest, dividends and rents imposed by the Income Tax Act of 1894 were unconstitutional. This case was heard twice, though only the second hearing resulted in a decision; the justices, feeling that the opinions written had not adequately explained their view of the situation, wished to rehear the case. After the first hearing, Gray wrote that he sided with the defendant, arguing that the tax was indeed constitutional. He was in the minority, however. After the second hearing, Gray changed his stance, joining with the majority in favor of the plaintiff. He also sided with the majority in Plessy v. Ferguson, a 7–1 ruling that upheld the constitutionality of racial segregation laws for public facilities as long as the segregated facilities were equal in quality. Gray served on the US Supreme Court for over 20 years, resigning in July, 1902, gravely ill. He was succeeded by a fellow Massachusetts native, Oliver Wendell Holmes, Jr., who, like Gray, previously served on the Massachusetts Supreme Judicial Court.