The New Zealand government has passed legislation clearing the way for two Hobbit films to be made in the country despite stiff protest by opposition MPs, who said it was a "day of shame".

The government's decision to rush through amended labour laws, part of a deal made with Warner Brothers Pictures to keep director Peter Jackson's lucrative project in his native New Zealand, has split public opinion.

Some union officials reportedly received death threats in the wake of a short-lived international boycott over working conditions.

Warner Brothers executives had said they would consider moving the production elsewhere, a move that could have cost the country $1.5bn (£700m) and damaged the reputation of its film industry. They flew to New Zealand earlier this week to negotiate with a delegation led by the prime minister, John Key.

The government announced a deal on Wednesday to keep the films in New Zealand, although it was forced to hand over tens of millions of dollars for the privilege.

"We were not prepared to see thousands of Kiwi jobs disappear and we were not prepared to see the hard work of the many talented New Zealanders who built our film industry from scratch put at risk," the labour minister, Kate Wilkinson, told parliament during the debate.

Included in the deal was an offer of $25 million (£11.8m), $15 million of that in tax breaks, and the law changes, which were pushed through without the normal process of referral to a parliamentary committee and public submissions.

"What is the government going to do next – give in to any multinational that asks for a labour standard to be diluted in return for some form of investment?" said an opposition MP, Charles Chauvel.

"This is a government which, in the words of the Financial Times today, has reduced New Zealand to client status of an American film studio."

Another opposition MP held up a redesigned national flag with the Warner Brothers logo in one corner.

Warner Brothers has declined several requests for comment, but Jackson said he was thrilled.

"We are grateful to the government for introducing legislation which shall give everyone in the film industry certainty as to their employment status," Jackson and his wife and collaborator, Fran Walsh, said in a statement.

Jackson's adaptation of Tolkien's Lord of the Rings trilogy was shot in New Zealand and amassed billions of dollars at the box office, boosting the local film industry, which has since contributed heavily to King Kong and Avatar.

The threatened loss of the movies drew thousands to the streets in protest earlier this week.

As part of the overall package, New Zealand is giving extra tax rebates for each Hobbit movie on top of the usual 15% , and will partly offset the costs of a joint marketing deal with Warner Brothers to promote the country as a film production and tourism destination.

The Hobbit is based on the adventures of Bilbo Baggins, a hobbit who lives in the land of Middle-earth that is filled with wizards, elves and other fantasy creatures. Bilbo goes on a quest to find treasure guarded by a dragon.

The book, first published in 1937, is the precursor to the Lord of the Rings trilogy which also takes place in Middle-earth.