Hopkinton and Marblehead this week formally pushed back against the MBTA Communities Act. The state law requires 177 cities and towns served by the public transit agency to adopt zoning changes to make it easier for multifamily housing to be built.

Both rejections were narrow. In Marblehead on Tuesday, residents voted 377-410 against the measure. The next day, in Hopkinton, the vote was 118 in favor and 126 opposed.

The two towns stand with a handful of municipalities against the law, but still have time to reverse course and meet state-imposed deadlines for compliance. Municipalities who don’t meet those deadlines risk losing funding from the state.

Elaine Lazarus, interim town manager in Hopkinton, said the Town Meeting vote was “a setback.” She said the town is committed to presenting another proposal at a special town meeting in order to achieve compliance with the law, likely in the fall.

Hopkinton is considered an adjacent community because of its proximity to the Southborough commuter rail station, and is required to zone for at least 750 additional units. Hopkinton has until Dec. 31 to submit a plan to the state to show how it will be compliant, which must include the town’s residents voting a majority in favor of the zoning changes.

Attorney General Andrea Campbell, who has sued Milton to enforce compliance with the MBTA Communities Act, urged both Hopkinton and Marblehead to reconsider their stance before the end of the year.

“While some remain wrongly focused on the towns that have had failed votes, a majority of communities are taking steps to comply with the MBTA Communities Law,” she said, “and we will continue to be a resource to all communities including Hopkinton and Marblehead who have until the end of 2024 to come into compliance.”

More than 60 communities have adopted multifamily zoning districts in response to the law so far.

“Right now, seniors, young families, and essential workers are being priced out of their communities due to a lack of available and affordable housing,” said Ed Augustus, secretary of the Executive Office of Housing and Livable Communities in a statement to GBH News.

He said the agency will continue to provide assistance to municipalities who are working to approve compliant zoning. Hopkinton and Marblehead both received $20,000 from Massachusetts Housing Partnership in 2022 for technical assistance to come into compliance with the law.

Town officials want to schedule special town meetings this fall, with the potential for a new vote.

Marblehead Town administrator Thatcher Kezer believes naysayers think the law is about building more units, and that's misinformation.

“This was a mandate to create the zoning. For development, but it was not a mandate to build,” he said. Kezer said the town wants to be in compliance, and there's a lot to lose by rejecting the law. He said Marblehead has received about $5 million in grants, which would be at risk.

“We have around $11 [million] to $15 million in project proposals that we're seeking from the state that would be impacted should we not pass this. So we are concerned about that,” he said.

The Executive Office of Housing and Livable Communities is providing consulting services to cities and towns that are drafting zoning districts to present at town meetings.

Other communities like Wakefield, Marshfield, Wrentham and Holden have refused to be compliant under the law so far, and have various deadlines to be in compliance, with the soonest being Dec. 31 of this year. They can hold new town meetings to change voters’ minds.

Other towns haven’t voted yet, but have officials and residents concerned about infrastructure costs, like sewer creation, that will come with the eventual expansion of multifamily housing.

Milton has gone as far as to pursue a lawsuit against the state, which is being heard before the state’s Supreme Judicial Court in October.