Massachusetts on Tuesday elected Democrat Maura Healey - who is openly gay - as its governor in the congressional midterm elections, becoming the first openly gay female governor in US history.

Healy, 51, snatched the post from Republicans after easily defeating her rival Geoff Diehl, according to NBC and Fox.

The Human Rights Campaign, which defends gay rights in the United States, praised Healy's victory.

"Massachusetts has embraced an equality and inclusion platform by electing an equality champion," the organization's interim president, Johnny Madison, said in a statement.

Healy's victory returns the state's governorship to Democrats after 8 years of Republican control led by Charlie Baker, who chose not to run for a third term.

And Healy, who will also become the first female governor of a state in Massachusetts, is expected, with the announcement of the final results, to inflict a severe defeat on her rival Diehl, who was supported by former President Donald Trump.

That result was to be expected as Healy, the attorney general of Massachusetts since 2014, comfortably led in the pre-election polls.

The current midterm elections mark the first time that gays have run for office in all 50 US states, in addition to Washington, DC.

Democrat Tina Kotik, also a lesbian, is facing a tough contest in Oregon for governor.

About 90% of the gay candidates in this election belong to the Democratic Party.