Ministers signed the agreement at 7pm after two days of crisis talks with studio executives who wanted more money than the Government was prepared to give, and sought assurances that labour law would be changed so there was no possibility of legal disputes that could have held up production.
The $670 million movies will go ahead, directed by Sir Peter Jackson, and Prime Minister John Key said tonight a long-term partnership had been achieved for New Zealand's $2.8 billion industry.
"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," he said.
"The Government is determined to use the opportunity that The Hobbit movies present to highlight New Zealand as a great place to visit, as well as a great place to do business."
Mr Key said agreement had been reached for the Government to offset $US10 million of Warner Brothers marketing costs through a "strategic partnership" that would promote New Zealand through all of the promotional material for the two movies.
"It means all the DVDs that promote the movies...and 50 million people bought the DVDs for Lord Of The Rings," he said.
"This is a huge opportunity to promote New Zealand and it's worth a lot of money."
Mr Key said the deal breaker was the agreement to change labour laws so there would be no ambiguity around legal definitions of a contract worker and an employee.
"We're not taking rights off workers," he said.
"But if someone offers their services as a contractor, they won't be able to go to court later and claim they're an employee."
The bill will go through Parliament tomorrow under urgency, and Mr Key said he already had enough support to ensure it was passed.
It will affect only the film industry.
"This is commercial reality," Mr Key said.
"Without this change, those movies would not be made in New Zealand."
Mr Key said Warner Brothers argued for more than the $20 million tax rebate - US$7.5 million per picture - which is on top of the standard 15 percent that big movies get.
"They could have held out for a lot more, I made it clear we had reached our limit," he said.
"We've done the business...there are bigger bucks overseas but they wanted to make the movies here."
Mr Key said he hadn't spoken to Sir Peter since the deal was made "but I'm sure he's going to be a very happy camper tonight".