Matthew Edward Gonzalez was born in McAllen, Texas. His father, a division chief for the international tobacco company Brown & Williamson, moved the family to New Orleans, Baltimore, and Louisville, Kentucky, before resettling in McAllen when Gonzalez was eleven years old. After graduating from McAllen Memorial High School, he attended Columbia University, from which he graduated in 1987. In 1990, he obtained a Juris Doctor degree from Stanford Law School.
Gonzalez began working as a trial lawyer at the Office of the Public Defender in San Francisco in 1991.
Gonzalez served one term on the San Francisco Board of Supervisors in the years 2001–2005. He was elected president of the Board in 2003. After losing the mayoral election in 2003, he chose not to seek re-election.
Gonzalez entered politics when he ran for San Francisco District Attorney in 1999. He campaigned to halt political corruption and marijuana prosecutions. Gonzalez lost to incumbent Terence Hallinan. In a field of five candidates, he finished third with 20,153 votes (11 percent of the total).
In 2000, a system of electing supervisors by district rather than citywide took effect. At the urging of Supervisor Tom Ammiano, Gonzalez moved from his home in the Mission District to run for supervisor in newly made District 5. In early November, shortly before the run-off election, Gonzalez switched party affiliations from the Democratic Party to the nascent Green Party. His opponent, Juanita Owens, tried to capitalize on many Democrats' ill feelings toward the Green Party in the wake of Ralph Nader's involvement in the acrimonious 2000 presidential election, but Gonzalez won the run-off election. He was part of a slate of candidates who wanted to change the direction of city policy, in opposition to the "Brown machine," a Democratic Party political machine that had dominated local politics for over 30 years behind Mayor Willie Brown, the Pelosi family, and other Democrats. His supporters saw his election as a turning point in local politics.
Gonzalez's critics considered him a stubborn and willful ideologue. When the Board put forth a resolution commending San Franciscan Congresswoman Nancy Pelosi for being elected House Minority Whip and being the first woman to hold that position, Gonzalez was the only board member who voted against it. Gonzalez said that supervisors should not issue commendations for winning partisan political positions and that he had written a personal note to Pelosi congratulating her, as she had done him for being elected board president. Gonzalez refused to meet with Brown during his first two years on the Board of Supervisors, saying he did so to avoid being subject to Brown's influence rather than as a matter of disrespect. Two sources reported that Gonzalez defied Brown by walking out of the mayor's State of the City address in 2002. However, Gonzalez later told SF Weekly that he was never in attendance.
In January 2003, Gonzalez was elected president of the Board of Supervisors after seven rounds of voting, most of which had Gonzalez vying for a majority vote with supervisors Aaron Peskin and Sophie Maxwell. When Peskin dropped out Gonzalez emerged the winner, counting among his supporters conservative Board member Tony Hall, who said when asked why he voted for Gonzalez, "Gonzalez is a man of integrity and intelligence who will carry out his responsibilities fairly and impartially."
Gonzalez hosted monthly art exhibits in his City Hall office. At the last reception, graffiti artist Barry McGee spray-painted "Smash the State" on the walls of the office as part of his exhibit." Gonzalez told the press that he knew his office would be repainted for the next occupant.
In August 2003, Gonzalez ran for Mayor of San Francisco in a bid to replace outgoing two-term mayor Willie Brown. On a ballot with nine candidates, Gonzalez finished second in the primary election on November 4 behind Gavin Newsom, a Democrat and fellow member of the Board of Supervisors who had been endorsed by Brown. Gonzalez received 19.6 percent of the total vote to Newsom's 41.9 percent. Because none of the candidates received a majority, a run-off election was held on December 9.
Gonzalez faced a difficult run-off election; only 3 percent of voters in San Francisco were registered to his Green Party the party to which he belonged. Although Gonzalez was endorsed by several key local Democrats, including five members of the Board of Supervisors, national Democratic figures, concerned about Ralph Nader's role in the 2000 presidential election, campaigned on Newsom's behalf. Bill Clinton, Al Gore, Jesse Jackson, Dianne Feinstein, and Nancy Pelosi all campaigned for Newsom. Gonzalez said about his candidacy, "They're scared, not of a Green being elected mayor, but of an honest person being elected mayor." Newsom won the runoff race by a margin of 11,000 votes, capturing 53 percent of the vote to Gonzalez's 47 percent
Following the mayoral contest, Gonzalez announced he would not seek re-election to the Board of Supervisors. He left office when his term ended in January 2005. He was succeeded by Ross Mirkarimi, a Green Party member and community activist who had also worked on Gonzalez's campaign. Gonzalez then opened law offices with fellow Stanford University alum Whitney Leigh. In May 2005 Gonzalez sought unsuccessfully to overturn the contract of San Francisco school Superintendent Arlene Ackerman. His law firm brought suit against a San Francisco hotel for not paying its workers the minimum wage; two wrongful death suits against Sacramento police for using tasers; against the city of San Jose and Ringling Brothers Circus for interfering with free speech rights of protestors; and against Clear Channel in a naming rights dispute over the locally owned San Francisco Warfield Theatre. It has also been involved in examining the New Year's Eve attack on the Yale a cappella group The Baker's Dozen in Pacific Heights.
In January 2008, Gonzalez, along with several other prominent Green Party members, launched Ralph Nader's 2008 Presidential Exploratory Committee to support a possible Nader candidacy. On February 28, 2008, four days after announcing his presidential bid, Nader named Gonzalez as his running mate for the 2008 presidential election.
Nader announced that he and Gonzalez would not seek the Green Party nomination but would run as independents. On March 4, 2008, Gonzalez announced that he had left the Green Party and had changed his voter registration to independent. The change, he said, was to accommodate states, including Delaware, Idaho and Oregon, that did not allow members of political parties to run as independents.
On October 18, 2008 Gonzalez and Nader held a large protest on Wall Street following the passage of the Troubled Asset Relief Program. Their opposition to the bailout was a key issue of the Nader/Gonzalez campaign, in contrast to the Democratic and Republican Party candidates who supported the bill.
Gonzalez participated in the third party vice-presidential debates, along with Constitution Party vice-presidential candidate Darrell Castle and Libertarian Wayne Allyn Root, held in Las Vegas, on November 2, 2008. The event was hosted by Free and Equal.org and Free & Equal Elections (FREE), an organization of political parties, independent citizens and civic organizations formed to promote free and equal elections in the United States.
In San Francisco, Gonzalez received fewer votes citywide when he ran for vice president in 2008 (3,682) than he received in District 5 (12,743) when he ran for supervisor in 2000.
In February 2011, Jeff Adachi appointed Gonzalez chief attorney in the Public Defender's Office In 2012, Gonzalez was criticized for taking a paid, month-long leave of absence to act as co-counsel for a corporation, Cobra Solutions, in its $16 million lawsuit against San Francisco. This was a violation of the San Francisco Public Defender's office rules of ethics, part of which states, "No employee may provide legal advice or legal representation...to any person or entity other than in the employee's official capacity." In 2016, Gonzalez represented Juan Francisco Lopez-Sanchez in the Kathryn Steinle murder case.