Police have apologised to investigative journalist Nicky Hager for breaching his rights during their 2014 investigation into his book Dirty Politics.
Mr Hager's home was searched by the police in October 2014, and in 2015 the High Court ruled that the warrant used for the search was "fundamentally unlawful".
Following that court case, there were still a number of other alleged breaches of Mr Hager's rights that needed to be resolved.
But in a settlement, announced today, Mr Hager's legal team said the police had accepted that they did not have reasonable grounds for the search, that they attempted to breach Mr Hager's journalistic privilege in multiple ways, and that they did not follow the rules when they obtained private information from third parties, including Mr Hager's bank.
"This is a very important agreement," Mr Hager said.
Mr Hager said the apology showed sources they were safe if they wanted to speak with a journalist.
"For three and a half years I've been working with people who were nervous about whether they were going to be found out if they spoke to me, and if they could really be confidential sources. And this decision is the very best thing possible to reassure people - for me and for the rest of the media - that people can be confidential sources and do the right thing and tell the public what is going on."
As part of the settlement, Mr Hager will receive substantial damages and a substantial contribution to his legal costs.
The amount he will receive will remain confidential.
"However, it gives the strongest possible indication that Police accept the harm they caused and are much less likely to treat a journalist this way again. The money will help support important work in years to coming," Mr Hager said.
Police assistant commissioner Richard Chambers said they accepted the settlement decision and had apologised to Mr Hager.
"Police acknowledge that the processes used to obtain the warrant and request other personal information about Mr Hager were unlawful," he said.
"Police investigation processes have since been updated in consultation with the IPCA and the Privacy Commissioner."
Mr Hager's lawyer Felix Geiringer said it was becoming increasingly difficult for journalists to get hold of confidential information.
"Everything's on computers, everyone's access information can be logged," he said.
"So if you're working for an organisation and you realise that what they're doing is wrong, it's now increasingly difficult to get that information out."
He hoped the settlement would send a message that sources were safe to approach journalists.
"This is a significant blow to opening up the channels again, and letting people know that if they do [give information] to a journalist it's going to be very difficult and very rare for the police to circumvent that and figure out who you are."
He said the only way a journalist was legally required to disclose a source was in the case of a court ruling.
Assistant police commissioner Richard Chambers said police accepted the settlement decision and acknowledged they used unlawful processes to get the warrant and ask for Mr Hager's personal information.
Mr Chambers said they had since updated their investigation processes, in consultation with the Independent Police Conduct Authority and the Privacy Commissioner.
This morning politicians were distancing themselves from the apology.
Police Minister Stuart Nash said he hoped both the police and Mr Hager could put the matter behind them and move on.
He said the police commissioner does not ask him to sign off search warrants and it was an operational matter.
"This is purely an issue between Mr Hager, the NZ Police service and the courts. My understanding is it's a confidential settlement."
"That's where it starts and ends as far as I'm concerned."
The police minister at the time, Anne Tolley, said she was never briefed on the raid.