Massachusetts Gov. Charlie Baker addresses reporters during a press conference in Lawrence, Massachusetts, Sept. 21, 2018. Credit: Charles Krupa | AP

BOSTON — Gov. Charlie Baker, a moderate Republican popular with voters in heavily Democratic Massachusetts, was re-elected Tuesday to a second four-year term.

Baker and Lt. Gov. Karyn Polito turned back a challenge from Democrat Jay Gonzalez, a former state budget official, and his running mate, Quentin Palfrey.

Baker touted the state’s strong economy and low unemployment, his administration’s progress in stabilizing the state’s finances without broad tax increases, and steps taken to tackle the opioid addiction crisis.

He also has distanced himself from President Donald Trump, who is deeply unpopular in the state. Questioning Trump’s “temperament” for the office, he said he blanked his ballot for president in 2016 and recently said he probably wouldn’t vote for Trump in 2020 if the president is again the Republican nominee.

Gonzalez criticized Baker for endorsing other pro-Trump Republicans in Massachusetts, including U.S. Senate candidate Geoff Diehl. Baker said he did so out of loyalty to the GOP ticket.

The Democrat, who served in the administration of former Democratic Gov. Deval Patrick, ran on a liberal platform that included a call for $3 billion in new taxes to improve education and transportation, and a single-payer health care system.

Baker steadfastly opposed new taxes and stressed bipartisanship and compromise as an antidote to the contentious political atmosphere in Washington and elsewhere. He forged strong working relationships with Democrats who hold firm control over the Legislature and other Democrats, such as Boston Mayor Marty Walsh.

Though Walsh endorsed Gonzalez, at least 10 other Democratic mayors backed Baker over their own party’s nominee, adding to the difficulty Gonzalez had in gaining traction during the campaign.

Baker’s liberal stance on many social issues helped make him a more comfortable choice for Democrats and left-leaning independents. He signed legislation in his first term to help ensure abortion rights continue in Massachusetts even if the U.S. Supreme Court should reverse Roe v. Wade, and a law that protects transgender people from discrimination in public accommodations, including the right to use restrooms and locker rooms that match their gender identity.

Polls taken during Baker’s first term showed that with the majority of the state’s voters, Baker’s recipe appeared to work. There were even polls that anointed Baker the most popular governor in the country.

At the same time, he’s drawn occasionally deep resentment from the conservative wing of his own party. More than one-third of Republicans voted in the September primary for Scott Lively, a Springfield minister with a long history of anti-LGBT sentiments and who called Trump “God’s man in the White House.”

Baker’s administration has faced challenges and endured setbacks. In 2015, winter storms crippled the Boston-area transit system known as the “T,” stranding riders and exposing antiquated infrastructure and shoddy financial management. Though the issues predated Baker’s tenure and he was credited with taking steps to stabilize the system, frequent breakdowns and delays continue to frustrate commuters.

An overtime abuse scandal rocked the Massachusetts State Police in recent months, leading to indictments against several officers and shaking public trust in the agency. Baker strongly defended his administration’s response, including the disbandment of an entire state police unit.

Though Gonzalez sought to exploit weaknesses in Baker’s record he struggled with low name recognition among voters and a massive fundraising deficit. Baker’s financial edge, which included support from a political action committee funded by the Republican Governor’s Association, allowed him to pepper the airwaves with ads long before any supporting the Democrat appeared.

Gonzalez portrayed Baker as a “status quo” governor who lacked the necessary vision to fix the state’s most pressing problems. To help pay for his proposed reforms, he called for taxing large private college endowments and a surtax on the wealthiest earners. Republicans said the money Gonzalez hoped to raise through those taxes wouldn’t come close to paying for all the increased spending he proposed.

Gonzalez frequently referred to himself the “little guy” in the race, a reference to both his underdog status and the fact that Baker stands more than a foot taller. The Democrat appeared to land a blow during the second of three debates when he asked Baker if he planned to vote for Diehl, who in 2016 served as co-chair of Trump’s presidential campaign in Massachusetts.

Baker stumbled in his answer, saying he hadn’t decided whether to vote for Diehl even though he had earlier endorsed him in his campaign against Democratic Sen. Elizabeth Warren. Baker was forced to backtrack after the debate, telling reporters he “misspoke” and did in fact intend to vote for Diehl.