After the unauthorised access was detected overnight on Thursday, the computer was shut down but was back online on Saturday night, a spokeswoman said.
The National Cyber Security Centre, part of the Government Communications Security Bureau, had been kept informed throughout.
The computer was used to run scientific models and services and no sensitive personal or client information was stored on it.
The United States last week charged five named Chinese military officers with hacking and stealing trade secrets.
Mr Key said cyber attacks were increasing with 134 in 2012 and 219 last year.
About 70 per cent were attacks on private sector entities and 30 per cent on public sector systems.
"These are quite sophisticated attacks on our both government and private sector systems."
The GCSB reform legislation last year allowed the bureau to work with private sector companies to try to protect them.
Mr Key would not hazard a guess about the motive for hacking into the Niwa computer.
But security specialist Paul Buchanan suggested in the National Business Review the hackers could be interested in the location of weather buoys or accessing links to weather satellites that could also have non-weather-related purposes.