WELLINGTON, New Zealand — Less than a month after 50 Muslim worshipers in the city of Christchurch were fatally shot in terrorist attacks on two mosques, New Zealand passed a law banning most semiautomatic weapons on Wednesday — a measure supported by all but one of Parliament’s 120 lawmakers.

The passage of the bill means temporary restrictions imposed by Prime Minister Jacinda Ardern six days after the massacre, to prevent New Zealanders from stockpiling guns before the law went into effect, will now be permanent. The swift action by lawmakers stands in stark contrast to similar efforts in the United States, where nationwide gun control proposals have stalled despite a series of mass shootings in recent years.

“New Zealand stands apart in its widespread availability of weapons of such destructive nature and force,” Ms. Ardern told Parliament on Wednesday. “Today that anomaly ends.”