Key said up to 143 soldiers from the New Zealand Defence Force would most likely work alongside their Australian counterparts at a military base in Taji, north of Baghdad.
In a statement to parliament, he said New Zealand was part of a 62-nation coalition against IS, also known as ISIL or ISIS, which has seized swathes of territory in Iraq and Syria.
Key described the Islamist extremist group as “barbaric”, saying New Zealand would “stand up for what’s right”.
“Sending our forces to Iraq is not an easy decision but it is the right decision,” he said.
“We cannot, and should not, fight Iraq’s battles for them –and actually Iraq doesn’t want us to.
“Our military can, however, play a part in building the capability and capacity of the Iraqi forces so they can fight IS themselves.”
Key said the mission would be reviewed after nine months and would not last more than two years.
The deployment was opposed by most political parties in a debate that followed Key’s statement, including two minor parties that support the centre-right government.
Key has said the risks posed to New Zealand from IS had increased, with 35 to 40 New Zealanders under surveillance because of their support for the militants.
New Zealand, part of the so-called “five eyes” intelligence network involving the United States, Britain, Australia and Canada, has faced pressure from allies to involve its military in the anti-IS effort.
The US and its allies face a long war against Islamic State, with one top general nominating Christmas 2017 as a possible turning point.
British foreign secretary Philip Hammond urged New Zealand to make its military expertise available when he visited Auckland this month.
“Frankly we’ve got used to New Zealand being there alongside us, alongside the US, the UK, Australia, as part of the family,” Hammond said.
In January, Key said New Zealand was expected to assist the military effort, adding “there has to be some contribution, it’s the price of the club”.
New Zealand did not participate in the US-led invasion of Iraq to oust Saddam Hussein in 2003. Instead it sent two 60-odd strong contingents of engineers to Basra in 2003-04 after a UN request for help in reconstruction efforts.
The country also sent a reconstruction team and small special forces contingent to join the NATO-led operation in Afghanistan in 2003.
The decade-long deployment to Afghanistan resulted in the deaths of 10 New Zealand soldiers.
Meanwhile, in Australia sources have told the ABC that a commitment of additional Australian troops to Iraq, likely to number in the hundreds, is imminent.
It is understood they will be part of a joint mission with New Zealand to train Iraqi soldiers.
In an address to the New Zealand parliament, Key told his countrymen the deployment would be alongside Australian soldiers.
“This is likely to be a joint training mission with Australia, although it won’t be badged an ANZAC force,” he said.
Officially, the Australian government has remained tight lipped.
But Defence Minister Kevin Andrews has welcomed the New Zealand decision.
Asked by the ABC if it would mean sending additional Australian troops, a spokesman for Andrews said that Australia’s commitment was “always under active consideration”.
“Australia continues to talk to Iraq, the US and our other partners about what we can do to support the Iraqi government,” the spokesman said.
Key’s announcement makes for awkward political timing for Australia’s Prime Minister Tony Abbott.
Abbott is due to make his first visit to New Zealand as Prime Minister on Friday.
It would be highly unusual for the prime minister to commit to sending troops abroad while himself on foreign soil.
If, like Key, he is to make an announcement in parliament, he has two sitting days remaining.