Going into Tuesday night, Massachusetts residents had a pretty good idea of how most races would shake out. The Associated Press declared Governor Charlie Baker and Senator Elizabeth Warren victors against their respective challengers within minutes of the polls closing.

But there were still a few surprising results in Massachusetts, starting with Question 1, which was expected to be one of the tighter contests decided Tuesday.

Only five communities in Mass. voted “yes” on controversial Question 1

The ballot measure would have set strict limits on the numbers of patients assigned to hospital nurses.

Advertisement

The overall result on that question was not a complete surprise, as polls indicated that most voters opposed the measure, but the margin of victory was higher than reported in recent polling.

Get Today in Politics in your inbox:

A digest of the top political stories from the Globe, sent to your inbox Monday-Friday.

A Suffolk University/Boston Globe poll conducted just two weeks ago showed about 59 percent of respondents said they opposed Question 1, while 32 percent supported it, and about 10 percent were undecided or did not answer.

On Tuesday, it appears the undecided crowd — and even some who were leaning toward “yes” — flocked to “no,” as statewide 70 percent of ballots cast opposed the measure, according to tallies as of Thursday morning.

Some communities have still not reported results, but most have, and they show the measure was approved in only one sizable community, winning by a narrow margin in Northampton. Otherwise, only a few small communities in the western part of the state and one on Martha’s Vineyard voted “yes.”

Only five communities voted “no” on Question 3

Only five communities voted “no” on question 3, which upholds a law in Massachusetts barring discrimination against transgender people in public spaces. And in each of those five communities, the “no” side won by less than 2 percentage points.

Advertisement

Polls prior to the election showed wide support for keeping the law on the books, with the most recent Suffolk/Globe poll finding 68 percent of respondents planned to vote “yes,” and 28 percent planned to vote “no.”

No town voted “no” on question 2

Question 2 creates a commission that will work to overturn the Citizens United Supreme Court decision that loosened rules on corporate and union money in politics. The October Suffolk/Globe poll found that 58 percent said they support the ballot measure, compared with 26 percent who said they would vote against it. The idea is apparently popular with voters because it carried every town that has submitted results.

Governor Baker nearly won Boston

Republican Governor Charlie Baker trounced his Democratic challenger, Jay Gonzalez, across the state, carrying all but a few communities, mostly in the Boston area and parts of Western Mass. But surprisingly, Baker was close to also winning a majority of votes in the reliably liberal city of Boston. Gonzalez won in Boston with 50.7 percent of the vote to Baker’s 49.3 percent, a difference of just about 3,000 votes, with 100 percent of precincts reporting. Compare that with 2014, when Democrat Martha Coakley ran up big margins against Baker in Boston, winning 66 percent of the vote to Baker’s 30 percent.

And another reminder that every vote counts

Away from the limelight, several local races around the state were decided by relatively slim margins. One glaring example was the contest for the seventh and final seat on the Dukes County Commission on Martha’s Vineyard. That was decided by a mere seven votes.