(CNN) -- The New Zealand government said Wednesday it has reached an agreement with filmmaker Peter Jackson and Warner Bros studios to ensure that the "Hobbit" movies will be made in the country.
A labor dispute between the filmmakers and New Zealand actors had threatened to derail the $500-million project from being shot there.
The two-film project is the predecessor story to "Lord of the Rings" -- a trilogy that was a box office smash worldwide.
Actors in New Zealand work as independent contractors. The New Zealand Actors Equity mounted a campaign to press for union wages and work standards.
They had called on their unions in other countries to boycott "The Hobbit" to press for a new contract.
In response, Jackson threatened to move production off-shore.
On Wednesday, Prime Minister John Key announced that an agreement had been reached -- but he did not elaborate.
"I am delighted we have achieved this result," Key said. "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 NZ on the world stage."
Key said lawmakers will introduce legislation Thursday to "clarify the distinction between independent contractors and employees as it relates to the film production industry."
"It is this clarification that will guarantee the movies are made in New Zealand," he said.
Filming is expected to start early next year, with "Lord of the Rings" actors Ian McKellen and Andy Serkis rumored to reprise their roles as Gandalf and Gollum.
"It's good to have the uncertainty over, and to have everyone now full steam ahead on this project," Key said.