Ian Fletcher, the country's top spymaster, has unexpectedly resigned.

Fletcher has been the Government Communications Security Bureau (GCSB) director for three years.

During that time the agency has endured a series of scandals over surveillance and revelations by whistleblower Edward Snowden.

The Minister Responsible for the GCSB, Chris Finlayson, said Fletcher was stepping down for family reasons.

"Mr Fletcher has been instrumental in the significant improvements that have taken place at the GCSB over the past three years, where he has led the implementation of the Kitteridge review and increased the public openness and accountability of the organisation," he said.

Finlayson said Fletcher was looking forward to "pursing other interests in due course".

"I thank him for his leadership of the GCSB and wish him all the best for the future," he said.

Fletcher will finish at the end of next month before a review of the security services gets under way.

An acting director will fill in.

Fletcher's departure will spark a search for a replacement for the top security job.

His appointment was mired in controversy after it emerged he was a former schoolmate of Prime Minister John Key, who urged him to apply for the position.

Opposition parties have immediately turned their attention to Fletcher's replacement - and cross party agreement over the appointment.

The resignation also raises questions about the upcoming security services review, and what it might for GCSB.

Labour leader Andrew Little said the recruitment process must be "proper and open."

"It can't be shoulder-tapping the Prime Minister's mates. It needs to be done properly. This will be a test for the Government about whether they understand that they need to win back the confidence of many New Zealanders in the security services.

"If they wish to involve the Opposition then I think that is a sensible way to do it."

Little met with Fletcher just before Christmas and said he gave no indication he was about to leave. "It comes very much as a surprise."

"This makes me think that maybe they have indicated something to him about what they want to achieve from the review that he doesn't like, and so he's going now."

Green party MP Kennedy Graham said Fletcher was "hand-picked" for the role by Key. "He has been director during a period of unprecedented politicisation of the intelligence services."

He also accused Key of using the GCSB as "his own personal protection service."

"It is crucial that there is cross party support for the appointment of any future director and that the GCSB, and its director, are seen to be scrupulously politically neutral," he added.