Mr Key said plans to withdraw the troops next March remained the same.
Defence Force Chief Lieutenant-General Rhys Jones said the man was one of 15 Special Air Service (SAS) soldiers that responded to information about a planned attack in the Afghan capital Kabul.
"The operation was to disrupt that attack before it occurred, we seem to have hit upon a group that was willing to fight back,'' Lt Gen Jones said.
The SAS team, which was supporting the Afghan Crisis Response Unit, was attacked as it tried to cordon off a compound in the Wardak province near Kabul, where the insurgents behind the planned attack were believed to be.
"The people in that compound opened fire with rifle fire, and there were also some explosions.''
The battle started at about 9am (NZT).
The New Zealand soldier was shot in the head shortly after the firefight began. He was taken to a medical facility by helicopter, but died on the operating table.
Lt Gen Jones said the operation in Kabul was ongoing, and there were no reports of other New Zealand casualties.
"There are some injuries to a child who was in the compound as well, and a male, a fighting-aged male. Details of how they sustained those injuries are yet to be confirmed.''
Prime Minister John Key expressed his condolences to the soldier's family and the defence force.
"The SAS is our premier combat unit and its soldiers face very volatile and dangerous conditions in order to help the people of Afghanistan,'' Mr Key said.
"The news that one of our soldiers has fallen is devastating for our SAS, for the New Zealand Defence Force, and for all New Zealanders.''
The death forced a change in Mr Key's plans for tonight, including cancelling arrangements to host Georgian Prime Minister Nikoloz Gilauri at a Rugby World Cup match in Palmerston North.
"I'm going to go to Palmerston North to have dinner with him tonight, but I'm going to ask him to understand the position that New Zealand faces. I think it would be insensitive for me to go to the game.''
Mr Key said he still intended to go to Australia for the National Rugby League grand final on Sunday.
Defence Minister Wayne Mapp said further details about the Afghanistan operation and the dead soldier would be released tomorrow.
"We're expecting a similar process to how Corporal Grant was brought home. A lot of that will depend on the wishes of the family,'' he said.
"Some family members, for cultural reasons, wish someone to be with the body at all times, which means that would have to be on a military flight.
Dr Mapp said the details would be addressed once the family had had some time to deal with the loss.
"My aroha and condolences go to his family on this most difficult of days.''
Labour Leader Phil Goff, whose nephew Lieutenant Matthew Ferrara died in Afghanistan in 2007 while serving with the United States Army, also offered his support to the family of the slain man.
"I guess I understand better than most how his family and how his friends will be eeling at this time.''
Mr Goff said it was not the time to talk about the rights and wrongs of the SAS presence in Afghanistan.
"This is the time to stand alongside the family and share with them their grief and their sense of tragedy at this loss.''
Green Party co-leader Russel Norman repeated his call for SAS troops to be withdrawn from Afghanistan, saying the situation was one of "civil war'' not global terrorism.
The man is the second New Zealand SAS soldier to die in Afghanistan, following the death of Corporal Doug Grant last month.
Corporal Grant, 41, was killed after an attack by the Taliban at the British Council offices in Kabul.
Parliamentary business was put on hold briefly this afternoon to note the soldier's death.