Image caption Protestors took to the streets of New Zealand earlier this week

Two movies based on The Hobbit will be filmed in New Zealand as planned, the country's prime minister has confirmed.

The announcement follows two days of talks with Hollywood executives over whether the Lord of the Rings prequels should be shot in the country.

Warner Bros and New Line had considered taking the production elsewhere after acting unions threatened to boycott the films in a row over wages.

"I am delighted we have achieved this result," PM John Key said at 0720 BST.

"Making the two Hobbit movies here will not only safeguard work for thousands of New Zealanders, but it will also follow the success of the Lord Of The Rings trilogy in once again promoting New Zealand on the world stage."

All three films in that blockbuster series were shot in New Zealand, the homeland of their director Peter Jackson.

Hundreds took to the streets earlier this week to protest against the possibility of moving The Hobbit elsewhere.

Filming on the two-part prequel, which Jackson will direct, is set to begin in February.

British actor Martin Freeman will take the lead role of Bilbo Baggins, played by Ian Holm in the original films.

It's good to have the uncertainty over John Key, New Zealand PM

As part of the arrangement, the New Zealand government will introduce legislation to clarify the distinction between independent contractors and employees working in the film production industry.

"The industrial issues that have arisen in the past several weeks have highlighted a significant set of concerns for the way in which the international film industry operates," Mr Key told reporters on Wednesday.

"We will be moving to ensure that New Zealand law in this area is settled to give film producers like Warner Brothers the confidence they need to produce their movies in New Zealand.

"It's good to have the uncertainty over, and to have everyone now full steam ahead on this project."