AMESBURY, Mass. — Voters in Amesbury have rejected a proposal to ban pot shops in the northeastern Massachusetts city.

The referendum on Tuesday’s ballot was defeated by a nearly 2-1 margin after strong opposition from community advocates and the organization that led the successful effort to legalize recreational marijuana in Massachusetts.

Under a bill approved by the Legislature last summer, any community where a majority of voters approved the statewide ballot question a year ago cannot bar marijuana retail stores from opening without first holding a referendum. About 58 percent of Amesbury voters supported legalizing pot.

The Marijuana Policy Project says it ran an online campaign to urge Amesbury voters to reject a prohibition on pot shops.

The state is expected to begin licensing the first stores in mid-2018 but no locations have yet been announced.