Matthew Gaines was born on August 4, 1840 near Alexandria, Louisiana to a female slave owned by the Martin Despallier family. Gaines taught himself to read from a white boy who smuggled in books. This boy may have been young Blaz Philipe Despallier, who lived on the estate and who would later become the sole heir of Alamo Hero Charles Despallier, his uncle. After being sold from the Despallier family, Gaines escaped from his new owner in Louisiana to Arkansas, and eventually made it to New Orleans, where he was captured and returned to his master. In 1859, Gaines was sold to Christopher Columbus Hearne, where he remained until 1863 when he tried to flee to Mexico. He was caught again and was forced to work as a runaway slave in Fredericksburg, Texas until the end of the war.
In 1869, Gaines was elected as a Senator of the Texas's 16th district in the Twelfth Texas Legislature. He gained a reputation for being a guardian of the newly-won rights of the African-Texans. Throughout his term, he addressed the issues of public education, prison reform, the protection of black voters, and tenant farming reformation. Gaines passionately and unflaggingly supported the forward movement that established the first public school system for all Texans and assisted in allowing Texas to take advantage of the federal Grant College Act, also known as the Morrill Act.
In 1870, Gaines played a strategic role in passing the Militia Bill, which created a state police force to combat lawlessness and to protect against voter intimidation. Even though his actions were sincere, Senator Gaines was generally a threat to the Democrats and even some Republicans found him troublesome. Gaines was elected to a six-year term to the Senate, but he only served four years. Denounced on the Senate floor by a Democratic opponent as a "flat-footer [sic] nigger" and threatened with death outside the legislature by racist whites, Gaines was indicted in 1871 on a charge of bigamy, causing his seat to be challenged. He was removed from office despite the fact that the charge was overturned. In 1875, he was arrested for making a civil rights speech in Giddings. He told his audience that "in the eyes of God, blacks are as good as whites; they should have pride and hold their heads up even in troubled times." Gaines continued to be active in politics and made his political views known in conventions, public gatherings, and from his pulpit.
In 1998, Activists on the campus of Texas A&M University suggested Gaines should have his statue on campus to counteract Confederate General Lawrence Sullivan Ross's statue. However, the project was abandoned in the wake of the Aggie Bonfire tragedy in 1999.
In 2016, his great-granddaughter Lori Bartley was running for US Congress against Sheila Jackson Lee.