Maura Healey, the barrier-breaking attorney general of Massachusetts, secured the Democratic nomination for governor on Tuesday, according to The Associated Press, putting her on track to become the first woman to be elected governor in the state.If Ms. Healey wins in November, and if another Democrat running for governor of Oregon, Tina Kotek, also wins, they would become the first two openly lesbian governors in the country.Ms. Healey cleared the Democratic field earlier this summer in a state that has elected a string of moderate Republican governors but where Ms. Healey is favored this time, making Massachusetts one of the Democrats’ best opportunities to flip a governor’s seat.In the race to succeed Gov. Charlie Baker, Ms. Healey will face Geoff Diehl, a right-wing former state lawmaker who was endorsed by former President Donald J. Trump and who defeated Chris Doughty, a businessman and more moderate Republican. Mr. Baker is a popular centrist Republican who decided against running for re-election after Mr. Trump’s endorsement of Mr. Diehl.“The choice in this election could not be more clear,” Ms. Healey told a crowd of supporters at a watch party in Dorchester earlier on Tuesday night, warning that whoever emerged from the Republican primary would “bring Trumpism to Massachusetts.” She added: “I will be a governor as tough as the state she serves.”Ms. Healey was the first openly gay attorney general in the nation — she was elected to that office in 2014 — and her history-making potential this year has energized some Democrats in a proudly progressive state that has never elected a woman to serve as governor. Jane M. Swift served as the state’s first female governor; as lieutenant governor she assumed the role after then-Gov. Paul Cellucci became ambassador to Canada in 2001.“For women who have been around for awhile, and for young women wanting to look up to what’s possible — I can’t believe this is actually happening,” Deb Kozikowski, the vice chair of the Massachusetts Democratic Party, said of Ms. Healey. “She’s breaking barriers right, left and sideways.”Ms. Kotek, the former speaker of the Oregon House of Representatives and the Democratic nominee for governor in that state, faces a more competitive race in November.“There are over 20 million openly L.G.B.T.Q. adults in this country as we speak right now, and in terms of elected officials to the highest seats in their states, or in this country, we still have work to do, right, to be represented,” said JoDee Winterhof, senior vice president for policy and political affairs at the Human Rights Campaign, the nation’s largest L.G.B.T.Q. rights organization. Referring to both Ms. Kotek and Ms. Healey, she added, “It’s really an exciting time that we would not only break the record, we would double the number on election night.” In another statewide race, Bill Galvin, a Democrat who has been Massachusetts’ secretary of state for more than 25 years, defeated a primary challenge on Tuesday. He had presented himself as an experienced hand who could protect the election system from right-wing interference. His opponent, Tanisha Sullivan, an N.A.A.C.P. branch president, had argued that Massachusetts should do more to increase voter participation among marginalized groups.And Andrea Campbell, a former Boston councilwoman, won the Democratic nomination for attorney general over Shannon Liss-Riordan, a labor lawyer — positioning Ms. Campbell to be the first Black woman elected to a statewide office in Massachusetts.Another milestone is likely after Kim Driscoll, the mayor of Salem, Mass., won the Democratic primary for lieutenant governor: No state has ever elected women to both the governorship and the lieutenant governorship at the same time. Voters in at least two other states — Republicans in Arkansas and Democrats in Ohio — also nominated women for both offices this year.Like other states in the East, Massachusetts has a track record of embracing Republican governors, such as Mr. Baker and Mitt Romney, despite the liberal bent of the electorate. But polls have shown Ms. Healey with a strong lead, as relative moderates like Mr. Baker and Mr. Romney find themselves increasingly isolated in a Republican Party lurching ever farther to the right. In her speech on Tuesday night, Ms. Healey praised Mr. Baker, saying he had “led with respect” and “refused to engage in the politics of division and destruction that we’ve seen across this country.” When she thanked him for his service to the state, the audience applauded.“Unfortunately, Geoff Diehl and Chris Doughty will put us on a different path,” she said, before the Republican race was called.Mr. Trump, who lost Massachusetts by 33.5 percentage points in the 2020 general election, attended a tele-rally for Mr. Diehl on Monday, declaring that Mr. Diehl would “rule your state with an iron fist” and push back on the “ultraliberal extremists.” Mr. Doughty, for his part, campaigned with moderates like Gov. Chris Sununu of New Hampshire and was endorsed by the editorial board of The Boston Globe in the primary.“President Trump still has a powerful message and an impact on politics in Massachusetts,” said Jim Lyons, the chairman of the Massachusetts Republican Party, which formally backed Mr. Diehl.Mr. Diehl was the overwhelming favorite at the state Republican convention. His primary victory is the latest sign that Mr. Trump has refashioned the Republican Party in his image up and down the ballot and across the country, including in the Northeast, where moderate Republicans long thrived even as they shrank in number. Indeed, Mr. Baker, who defied Mr. Trump during his time in office and carved out a distinctive brand, has topped lists as the most popular governor in the country.On the other side of the aisle, Democratic-leaning women, in particular, have appeared especially energized since the overturning of Roe v. Wade earlier this summer.Ms. Healey, bolstered by a raft of endorsements from liberal organizations, labor and the political establishment, has had the field to herself since State Senator Sonia Chang-Díaz exited the primary contest in June, although Ms. Chang-Díaz was still listed on the ballot. That has given Ms. Healey a significant runway to focus on the general election and to engage in down-ballot races. Ms. Healey, who was a college basketball captain at Harvard and played on a professional team overseas, has often used discussion of sports in her campaigns. In her Twitter bio, she describes herself as, among other things, a “baller.”“I believe in teamwork,” she said in a recent campaign ad. “I’ve seen it on the court and in the court as your attorney general.”During her time as attorney general, the state participated in major cases, including against Purdue Pharma for its role in the opioid addiction crisis, and in a climate-related investigation of Exxon. She has also focused on assisting student borrowers and homeowners, and drew national attention for repeatedly suing the Trump administration.“I have a message for President Trump,” she declared at the 2017 Women’s March in Boston, after Mr. Trump was inaugurated. “The message from the people of Massachusetts: We’ll see you in court.”She has also worked to recruit more women to become Democratic attorneys general. In the race to succeed her in the attorney general’s office, Ms. Healey endorsed Ms. Campbell.At her election night party, Ms. Healey alluded to her frustrations with a toxic political climate, saying that she was “tired of the anger” and of the division. “When we see what’s happening with the Supreme Court and across this country, we need to lead — this is a time when Massachusetts must lead,” Ms. Healey said.She wrapped up with a plea that nodded to her basketball days: “I ask you, as a former point guard, to leave it all with me on the court.” More