The two candidates for governor met for their first debate Wednesday night and each used the opportunity to try to paint their opponent as someone whose ideas are out of step with Massachusetts values and everyday Bay Staters.

Republican Geoff Diehl, a former state representative and onetime U.S. Senate candidate from Whitman, and Democrat Maura Healey, who burst onto the political scene eight years ago and has served as attorney general since, debated face-to-face for the first time 27 days before Election Day, which is Tuesday, Nov. 8 this year. But in this era of mail-in and early voting, the pool of voters that the campaigns might be able to sway to their side is already starting to shrink each day.

Healey has been the odds-on favorite even since before she formally jumped into the race, but Diehl and the MassGOP are hoping that enthusiasm about an immigrant licensing law repeal effort and a rejection of "radical" progressive ideas will help carry him to victory. The candidates seemed to approach Wednesday night's debate hosted by NBC10 Boston, Telemundo Boston and NECN accordingly: the Democrat was measured and careful not to answer many questions that could pin her down, while the Republican came prepared with barbs to try to put his opponent on her heels.

Right off the bat, Diehl went after Healey on energy policy and revived a theme he raised two weeks ago when held a press conference on the sidewalk outside the State House, trying to keep the high costs of living and doing business in Massachusetts on voters' minds this campaign season. He laid blame at Healey's feet for opposing efforts as attorney general to expand natural gas pipeline capacity in Massachusetts -- which could eventually bring energy prices down but likely at the expense of the state's carbon emissions reduction requirements and at a cost to ratepayers.

"My goal as governor is to make sure I listen to you, work hard for you and make sure that this state goes in the right direction economically. My opponent, unfortunately, is driven by ideology that is also pushing for energy solutions that are unavailable at this time," Diehl said. He added, "My opponent believes that we should be fossil fuel-free by 2030 and yet, with the renewables that are out there, there's no way to get there. We need to get from A to B responsibly. I'm for renewable energies, but we can't do it irresponsibly. She's gonna bankrupt our state, bankrupt our households, if we trust her energy policy."

Healey said she was happy to talk about her opposition to new natural gas pipelines in Massachusetts. She said she "actually said no to the pipelines because they wanted to charge us as ratepayers rather than foot the bill themselves."

"I saved ratepayers four and a half billion dollars, Geoff, that's what I've done for ratepayers," the attorney general, who serves as the state's ratepayer advocate, said.

For her part, Healey was quick to remind viewers of Diehl's ties to Donald Trump, calling the twice-impeached former president her opponent's "chief benefactor and supporter" and telling voters that this is a high-stakes election because of Diehl's connection to Trump.

"My opponent is Donald Trump's candidate for governor. I'd be honored to be yours," Healey said. She later added, "My opponent has said recently that he backs Donald Trump 100 percent of the time. He has said he wants Donald Trump to be president in 2024. He chaired his presidential campaign. He continues to play from the Trump playbook and wants to bring Trumpism to Massachusetts. I will continue to talk about this, Geoff, because those are values, those are principles, those are ways that we have rejected time and time again."

Diehl said all of the Trump talk is a "distraction" that Healey and the media like to talk about instead of facing questions about affordability in Massachusetts.

"You're gonna hear about Donald Trump because it's Halloweentime and that's her boogeyman, that's what the media likes to talk about, is Donald Trump," Diehl said.

Watch the debate:

Two other national issues were part of Wednesday's discussion: immigration policy and abortion rights. Diehl and Healey agreed on the need for national immigration reform without getting into specifics, and Diehl answered a question about his support for the effort underway to repeal the state's new law that would make immigrants living in Massachusetts without legal status in the country eligible for driver's licenses.

The question posed to Healey on immigration policy was whether Massachusetts should declare itself a "sanctuary state," but she did not answer. She said that she knows "that term has different meanings to different people" and instead voiced her support for federal reform.

On abortion rights, Healey attempted to paint Diehl as the candidate who would "ban abortion," but he said that was not exactly the case. The Republican said he "appreciated that the Supreme Court overturned Roe v. Wade" but conceded that he would have to put his personal views on the back burner if elected to lead Massachusetts.

"When I was born, my parents weren't married. And they made a choice at the time. Roe v. Wade was not the law and so they had me. So that shapes my view on abortion, of course, but again, my personal view on abortion is not what I do as governor," Diehl said. "My job is to work within the boundaries of the Legislature and the laws that they've said. Sometimes you need to set your own personal opinions aside for the good of the state."

The corner office will be open by virtue of Gov. Charlie Baker and Lt. Gov. Karyn Polito deciding they would not be candidates for elected office this year. But the popular two-term Republican governor was not mentioned Wednesday night until Healey, the Democrat in the race, brought him up to say that she supports his tax reform proposals.

And while the candidates clashed on big-picture issues, Wednesday night's debate made clear that they also have some overlap on state and local issues, like the need for more housing at all price points, the importance of fixing the MBTA and helping that agency attract new workers, and tax relief for residents.

At the end of the hour-long debate, moderator Latoyia Edwards attempted to get quick, rapid responses from both candidates on some lighter fare. Diehl was game and gave a direct answer to each question, but Healey equivocated on both and refused to answer.

What grade would they give Gov. Baker for his time in office? Diehl said he'd give the governor a B and acknowledged the difficult job of working with Democrat supermajorities in the Legislature. Healey would only say that the Republican has done a "really good job."

"Not a teacher, I'm not going to give grades," she said.

And what aspect of the job of governor is each candidate not looking forward to? Diehl said it would be the additional time he'd have to spend away from his family.

"I'm just here to ask for the voters' support and hopefully have success on Nov. 9," Healey said, mentioning the day after Election Day.