(Bloomberg) -- New Zealand will ban military style semi-automatics and assault rifles and establish a nationwide buyback of the weapons in the wake of a terrorist attack on two mosques that left 50 people dead.

The ban takes immediate effect to prevent the stockpiling of weapons while the legislation is being drafted, Prime Minister Jacinda Ardern told reporters Thursday.

“I strongly believe that the vast majority of legitimate gun owners in New Zealand will understand that these moves are in the national interest, and will take these changes in their stride,” she said in a statement.

In sharp contrast with the U.S., where a string of gun massacres have failed to spur political action, Ardern’s announcement comes just days after the worst mass shooting in New Zealand’s modern history. On March 15, a lone gunman attacked Muslim worshippers during afternoon prayers in the South Island city of Christchurch, filming and live-streaming the attack to social media.

Police recovered two semi-automatic weapons, two shotguns and a lever-action firearm, which the attacker could own legally because he had a category-A gun license. A loophole in the law makes it easy to convert standard semi-automatics, which hold up to seven bullets, to military-style weapons by inserting an unregulated high-capacity magazine.

The buyback could cost the government between NZ$100 million and NZ$200 million ($140 million), Ardern said. Exemptions will be made for shotguns and 0.22 caliber rifles for farmers and hunters.

New Zealand’s response to the mosque shootings echoes that taken by Australia, which acted quickly to tighten gun laws after the 1996 Port Arthur massacre left 35 dead.

Prime Minister John Howard’s government pushed through legislation that banned certain semi-automatic weapons and introduced new licensing rules. A national firearms registry was established, and the government bought back and destroyed 640,000 civilian-owned guns.

Televised images from the time show truckloads of weapons being dumped.

After the reforms, the total number of homicides involving a firearm decreased by half, and the number of gun-related deaths also fell. The changes have been credited with all but ending mass shootings in the country.

While New Zealand’s homicide rate is well below the global average, gun ownership has risen in the past decade to become one of the world’s highest rates per capita. Police estimated a civilian armory of 1.5 million firearms at the end of 2017. The South Pacific nation has a population of less than 5 million people.

To contact the reporters on this story: Tracy Withers in Wellington at twithers@bloomberg.net;Matthew Brockett in Wellington at mbrockett1@bloomberg.net

To contact the editors responsible for this story: Edward Johnson at ejohnson28@bloomberg.net, Peter Vercoe

©2019 Bloomberg L.P.