By Robin Emmott

BRUSSELS (Reuters) - Turkey has fired hundreds of senior military staff serving at NATO in Europe and the United States following July's coup attempt, documents show, broadening a purge to include some of the armed forces' best-trained officials.

In a classified military dispatch seen by Reuters, 149 military envoys posted to the alliance's headquarters and command centers in Germany, Belgium, the Netherlands and Britain were ordered on Sept. 27 to return to Turkey within three days.

Most were dismissed from service on their arrival, arrested and imprisoned, according to a Turkish military official at NATO and two farewell letters sent by departing Turkish officials emailed to colleagues at NATO and seen by Reuters.

One of those letters wrote of a "witch-hunt" of senior air force commanders serving overseas.

In total, about 400 military envoys have been fired so far, the Turkish military official said. Two non-Turkish NATO staff familiar with the situation confirmed that Turkish personnel are being recalled but did not have more details.

Although the number of dismissals is a small fraction of the 100,000 judges, police, teachers and soldiers to be suspended or fired since the failed coup, the decision to target some of the most highly-trained staff in prestigious foreign posts underscores the depth of President Tayyip Erdogan's purge.

Turkish officials say the scale of the crackdown, which has broad popular support at home, is justified by the gravity of events on July 15, when rogue soldiers commandeered tanks, fighter jets and helicopters, bombing parliament and government buildings in their attempt to seize power. More than 240 people, many of them civilians, were killed.

But the dismissals at NATO raise questions about Turkey's strategy after the failed coup, as Erdogan seeks closer ties with the alliance's Cold War foe Russia.

Turkey is a vital ally to the West in the war against Islamic State militants and in tackling Europe's migrant crisis. It is also one of the main troop contributors to NATO's training mission in Afghanistan.

Of the 50 military staff posted to the Turkish delegation at NATO's headquarters in Brussels, only nine remain, according to the Turkish official who spoke to Reuters. Turkish military representatives were not present in recent meetings. "Turkey is not at the table," the official said.

Turkey's ambassador to NATO, who runs a 30-strong diplomatic team at the alliance HQ, declined to comment.

A NATO official said that Turkey has notified the alliance about military personnel changes at NATO commands in Europe and in the United States, adding that the issue has been discussed at a senior level between NATO and Turkish officials.

"We are confident that Turkey will keep its commitment to the rule of law when bringing the perpetrators of the coup to justice," the NATO official said.

A senior official in Ankara declined to go into details, saying only that Turkey had recalled some soldiers and diplomats after the coup attempt, some of whom had failed to return. "Turkey called back certain military personnel and diplomats working abroad after the coup," the senior official said, adding that not all of those recalled were being punished.

"Those who do not return to Turkey or try to seek asylum abroad must be held to account. We expect our allies to back us on this, and not to support coup plotters if they were involved," the official said.

"UNFORTUNATE FAREWELL"

Colleagues of those recalled and arrested suspect they are accused of being part of the military faction that seized bridges and roads and attacked Turkey's parliament on July 15. However, they say no charges have been made and no explanation given. They deny any wrongdoing.

"We were at our desks abroad at the time of the attempted coup," said the official, who has been called back to a meeting in Ankara this week and believes he is likely to be dismissed and arrested. "We had no reason to undermine the government."

Some of those fired have not returned to Turkey for fear of prison sentences. They have had their passports revoked, bank accounts blocked and pension rights canceled. Spouses and relatives who are still in Turkey are banned by police from leaving the country and some are imprisoned, according to the two farewell letters seen by Reuters.

"They took everything from me, even my family," said a U.S.-educated Turkish fighter pilot instructor, who was sent to NATO in Brussels for a three-year posting and was fired in August. The person has now requested asylum in Belgium.

"I have not been notified of any charges against me."

Erdogan and the government blame the network of Turkish Islamic cleric Fethullah Gulen, who has lived in self-imposed exile in the United States since 1999, for masterminding the coup. They accuse his followers of infiltrating the military and state institutions over decades in a bid to seize power.

But dismissed NATO soldiers say they were targeted because of their Western outlook and education in Europe and the United States. They believe that puts them at odds with Erdogan's vision of an Islamic Turkey inspired by the Ottoman empire, unable to fit in with what they see as Turkey's pious masses and a president forging a nation that will not be dictated to by foreigners.

One dismissed staff member, Colonel Aziz Erdogan, wrote: "The common denominator of these victims is that all of them have a ... Western educational background and secular mindset." Erdogan, who is no relation of the president, made the comment in a letter entitled "Unfortunate Farewell" to colleagues at NATO headquarters in Brussels.

(editing by David Stamp)