BAGHDAD - The issue of legal immunity for foreign troops in Iraq, which already torpedoed plans to keep a U.S. military presence in the country, has emerged as a key stumbling block in talks over the extension of a NATO training mission here.

As with the U.S., Iraq is insisting that all troops in its country must be subject to its laws and judicial system. The U.S. and NATO are leery of that, fearing that servicemen could not receive fair trials in a county where anti-Western sentiment runs high.

Iraq bases its demand on past incidents of violence.

Prominent among them are the 2007 shooting in Baghdad's Nisoor Square in which 17 Iraqis were killed by private American security guards and an incident in Haditha, when U.S. troops killed 24 Iraqi civilians.

The impasse forced the Obama administration to stick to a previous agreement to withdraw all American troops by the end of the year. The same issue could torpedo an extension of the NATO trainers, despite Iraq's stated wishes.

In July, Iraqi Prime Minister Nouri al-Maliki requested that the alliance extend the NATO Training Mission in Iraq until the end of 2013.

The goal of the training mission is to help develop Iraqi commanders at or above battalion level. The Iraqi forces have received training on individual weapons and how to manoeuvr as small units, but they have never been trained on how to manoeuvr as a large unit or to co-ordinate air and ground forces, for example.

Advisers mentor faculty at Iraq's National Defence University and conduct an exchange program in which Iraqi officers are sent for staff training in participating countries.

Officials and diplomats familiar with the situation say talks on an extension of the training program -- which NATO has operated for the past eight years -- are stuck on the issue of legal protection for the roughly 130 advisers from 13 NATO nations and Ukraine who would stay in Iraq next year.

"The immunity issue is the main complicating factor," said a diplomat from a non-NATO nation who could not be identified under standing rules.

"Lawyers are currently looking at options," the diplomat said. "The whole issue of trainers in this field is very much caught up in the wider internal political battles."

Another official said there are concerns "...about the direction of negotiations right now because the Iraqis do appear to be holding fast to their position that there will be no discussions of granting legal protections to NATO personnel."

Speaking separately, three Western officials also said it remains unclear whether a compromise can be forged on the immunity issue by the year-end deadline. All the officials spoke on condition of anonymity due to the sensitivity of the issue.

NATO operates under the same agreement forged in 2008 between the U.S. and Iraq that allows U.S. troops to operate in Iraq without being subject to the local judicial system, but that agreement expires at the end of the year.

A member of the Iraqi parliament's security and defence committee, Qassim al-Aaraji, acknowledged that the immunity issue is the key sticking point.

"The same immunity problem of the American trainers' agreement is facing us today with NATO," he said. Al-Aaraji said Iraqis are especially sensitive to the immunity issue after incidents in which coalition forces or security contractors injured or killed Iraqis and did not face trial in Iraq.

Any eventual agreement between Iraq and NATO must be approved by NATO's 28-nation governing body.

Working with NATO would be a way for Iraq to expand its relationships with respected international organizations and end some of the isolation that their military and country has suffered for decades.

One official said the Iraqis' current negotiating stance is jeopardizing that relationship.

Another problem that the NATO mission must overcome is the loss of its main source of logistics support when the U.S. presence ends, the officials said. Alternative plans have been made for participating countries to provide transport and other services to the contingent.

Also, negotiators are also looking at the issue of sharing the costs of the mission between participating nations and the Iraqi government.

In Brussels, NATO declined to confirm details of the negotiations, but said alliance staff had conducted a technical visit to Baghdad in recent weeks to discuss the training program.

"The Iraqi government has asked NATO to extend its mission, and this visit and the ongoing dialogue is helping to work out the details for such an extension," said a NATO official who could not be identified in line with alliance rules.